2020-09-20 20:33:16 +01:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de>
|
|
|
|
SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2016 Chantara Tith <tith.chantara@gmail.com>
|
|
|
|
SPDX-FileCopyrightText: 2017-2018 Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
SPDX-FileCopyrightText: 2018 Huzaifa Faruqui <huzaifafaruqui@gmail.com>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2015-06-04 01:29:22 +01:00
|
|
|
|
|
|
|
#include "core/copytargetdevice.h"
|
|
|
|
|
|
|
|
#include "backend/corebackend.h"
|
|
|
|
#include "backend/corebackendmanager.h"
|
|
|
|
|
|
|
|
#include "core/device.h"
|
|
|
|
|
|
|
|
/** Constructs a device to copy to.
|
2015-07-13 15:16:36 +01:00
|
|
|
@param d the Device to copy to
|
2017-10-26 16:20:21 +01:00
|
|
|
@param firstbyte the first byte on the Device to write to
|
|
|
|
@param lastbyte the last byte on the Device to write to
|
2015-06-04 01:29:22 +01:00
|
|
|
*/
|
2017-10-26 16:20:21 +01:00
|
|
|
CopyTargetDevice::CopyTargetDevice(Device& d, qint64 firstbyte, qint64 lastbyte) :
|
2015-07-13 15:16:36 +01:00
|
|
|
CopyTarget(),
|
|
|
|
m_Device(d),
|
2015-07-22 14:48:03 +01:00
|
|
|
m_BackendDevice(nullptr),
|
2017-10-26 16:20:21 +01:00
|
|
|
m_FirstByte(firstbyte),
|
|
|
|
m_LastByte(lastbyte)
|
2015-06-04 01:29:22 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Opens a CopyTargetDevice for writing to.
|
2015-07-13 15:16:36 +01:00
|
|
|
@return true on success
|
2015-06-04 01:29:22 +01:00
|
|
|
*/
|
|
|
|
bool CopyTargetDevice::open()
|
|
|
|
{
|
2017-12-06 21:33:31 +00:00
|
|
|
m_BackendDevice = CoreBackendManager::self()->backend()->openDeviceExclusive(device());
|
2015-07-22 14:48:03 +01:00
|
|
|
return m_BackendDevice != nullptr;
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
2018-01-24 15:22:42 +00:00
|
|
|
QString CopyTargetDevice::path() const
|
|
|
|
{
|
|
|
|
return m_Device.deviceNode();
|
|
|
|
}
|