File indexing completed on 2024-05-05 05:48:39
0001 /* 0002 SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de> 0003 SPDX-FileCopyrightText: 2016-2018 Andrius Štikonas <andrius@stikonas.eu> 0004 SPDX-FileCopyrightText: 2019 Yuri Chornoivan <yurchor@ukr.net> 0005 0006 SPDX-License-Identifier: GPL-3.0-or-later 0007 */ 0008 0009 #ifndef KPMCORE_COPYTARGETFILE_H 0010 #define KPMCORE_COPYTARGETFILE_H 0011 0012 #include "core/copytarget.h" 0013 0014 #include <QtGlobal> 0015 #include <QFile> 0016 0017 class QString; 0018 0019 /** A file to copy to. 0020 0021 Repesents a target file to copy to. Used to back up a FileSystem to a file. 0022 0023 @see CopySourceFile, CopyTargetDevice 0024 @author Volker Lanz <vl@fidra.de> 0025 */ 0026 class CopyTargetFile : public CopyTarget 0027 { 0028 public: 0029 explicit CopyTargetFile(const QString& filename); 0030 0031 public: 0032 bool open() override; 0033 0034 qint64 firstByte() const override { 0035 return 0; /**< @return always 0 for a file */ 0036 } 0037 qint64 lastByte() const override { 0038 return bytesWritten(); /**< @return the number of bytes written so far */ 0039 } 0040 0041 QString path() const override { 0042 return m_File.fileName(); 0043 } 0044 0045 protected: 0046 QFile& file() { 0047 return m_File; 0048 } 0049 const QFile& file() const { 0050 return m_File; 0051 } 0052 0053 protected: 0054 QFile m_File; 0055 }; 0056 0057 #endif