1 /*
2     SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de>
3     SPDX-FileCopyrightText: 2016-2018 Andrius Štikonas <andrius@stikonas.eu>
4     SPDX-FileCopyrightText: 2019 Yuri Chornoivan <yurchor@ukr.net>
5 
6     SPDX-License-Identifier: GPL-3.0-or-later
7 */
8 
9 #ifndef KPMCORE_COPYTARGETFILE_H
10 #define KPMCORE_COPYTARGETFILE_H
11 
12 #include "core/copytarget.h"
13 
14 #include <QtGlobal>
15 #include <QFile>
16 
17 class QString;
18 
19 /** A file to copy to.
20 
21     Repesents a target file to copy to. Used to back up a FileSystem to a file.
22 
23     @see CopySourceFile, CopyTargetDevice
24     @author Volker Lanz <vl@fidra.de>
25 */
26 class CopyTargetFile : public CopyTarget
27 {
28 public:
29     explicit CopyTargetFile(const QString& filename);
30 
31 public:
32     bool open() override;
33 
firstByte()34     qint64 firstByte() const override {
35         return 0;    /**< @return always 0 for a file */
36     }
lastByte()37     qint64 lastByte() const override {
38         return bytesWritten();    /**< @return the number of bytes written so far */
39     }
40 
path()41     QString path() const override {
42         return m_File.fileName();
43     }
44 
45 protected:
file()46     QFile& file() {
47         return m_File;
48     }
file()49     const QFile& file() const {
50         return m_File;
51     }
52 
53 protected:
54     QFile m_File;
55 };
56 
57 #endif
58