1 /*
2     SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de>
3     SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org>
4     SPDX-FileCopyrightText: 2016-2018 Andrius Štikonas <andrius@stikonas.eu>
5     SPDX-FileCopyrightText: 2018 Huzaifa Faruqui <huzaifafaruqui@gmail.com>
6 
7     SPDX-License-Identifier: GPL-3.0-or-later
8 */
9 
10 #ifndef KPMCORE_COPYTARGETDEVICE_H
11 #define KPMCORE_COPYTARGETDEVICE_H
12 
13 #include "backend/corebackenddevice.h"
14 #include "core/copytarget.h"
15 #include "util/libpartitionmanagerexport.h"
16 
17 #include <memory>
18 
19 #include <QtGlobal>
20 
21 class Device;
22 class CoreBackendDevice;
23 
24 /** A Device to copy to.
25 
26     Represents a target Device to copy to. Used to copy a Partition to somewhere on the same
27     or another Device or to restore a FileSystem from a file to a Partition.
28 
29     @see CopyTargetFile, CopySourceDevice
30 
31     @author Volker Lanz <vl@fidra.de>
32 */
33 class CopyTargetDevice : public CopyTarget
34 {
35     Q_DISABLE_COPY(CopyTargetDevice)
36 
37 public:
38     CopyTargetDevice(Device& d, qint64 firstbyte, qint64 lastbyte);
39 
40 public:
41     bool open() override;
firstByte()42     qint64 firstByte() const override {
43         return m_FirstByte;    /**< @return the first byte to write to */
44     }
lastByte()45     qint64 lastByte() const override {
46         return m_LastByte;    /**< @return the last byte to write to */
47     }
48 
device()49     Device& device() {
50         return m_Device;    /**< @return the Device to write to */
51     }
device()52     const Device& device() const {
53         return m_Device;    /**< @return the Device to write to */
54     }
55     QString path() const override;
56 
57 protected:
58     Device& m_Device;
59     std::unique_ptr<CoreBackendDevice> m_BackendDevice;
60     const qint64 m_FirstByte;
61     const qint64 m_LastByte;
62 };
63 
64 #endif
65