File indexing completed on 2024-05-05 05:48:39
0001 /* 0002 SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de> 0003 SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org> 0004 SPDX-FileCopyrightText: 2016-2018 Andrius Štikonas <andrius@stikonas.eu> 0005 SPDX-FileCopyrightText: 2018 Huzaifa Faruqui <huzaifafaruqui@gmail.com> 0006 0007 SPDX-License-Identifier: GPL-3.0-or-later 0008 */ 0009 0010 #ifndef KPMCORE_COPYTARGETDEVICE_H 0011 #define KPMCORE_COPYTARGETDEVICE_H 0012 0013 #include "backend/corebackenddevice.h" 0014 #include "core/copytarget.h" 0015 #include "util/libpartitionmanagerexport.h" 0016 0017 #include <memory> 0018 0019 #include <QtGlobal> 0020 0021 class Device; 0022 class CoreBackendDevice; 0023 0024 /** A Device to copy to. 0025 0026 Represents a target Device to copy to. Used to copy a Partition to somewhere on the same 0027 or another Device or to restore a FileSystem from a file to a Partition. 0028 0029 @see CopyTargetFile, CopySourceDevice 0030 0031 @author Volker Lanz <vl@fidra.de> 0032 */ 0033 class CopyTargetDevice : public CopyTarget 0034 { 0035 Q_DISABLE_COPY(CopyTargetDevice) 0036 0037 public: 0038 CopyTargetDevice(Device& d, qint64 firstbyte, qint64 lastbyte); 0039 0040 public: 0041 bool open() override; 0042 qint64 firstByte() const override { 0043 return m_FirstByte; /**< @return the first byte to write to */ 0044 } 0045 qint64 lastByte() const override { 0046 return m_LastByte; /**< @return the last byte to write to */ 0047 } 0048 0049 Device& device() { 0050 return m_Device; /**< @return the Device to write to */ 0051 } 0052 const Device& device() const { 0053 return m_Device; /**< @return the Device to write to */ 0054 } 0055 QString path() const override; 0056 0057 protected: 0058 Device& m_Device; 0059 std::unique_ptr<CoreBackendDevice> m_BackendDevice; 0060 const qint64 m_FirstByte; 0061 const qint64 m_LastByte; 0062 }; 0063 0064 #endif