File indexing completed on 2024-04-28 05:45:44
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_COPYSOURCEFILE_H 0010 #define KPMCORE_COPYSOURCEFILE_H 0011 0012 #include "core/copysource.h" 0013 0014 #include <QtGlobal> 0015 #include <QFile> 0016 0017 class QString; 0018 class CopyTarget; 0019 0020 /** A file to copy from. 0021 0022 Represents a file to copy from. Used to restore a FileSystem from a backup file. 0023 0024 @author Volker Lanz <vl@fidra.de> 0025 */ 0026 class CopySourceFile : public CopySource 0027 { 0028 public: 0029 explicit CopySourceFile(const QString& filename); 0030 0031 public: 0032 bool open() override; 0033 qint64 length() const override; 0034 0035 bool overlaps(const CopyTarget&) const override { 0036 return false; /**< @return false for file */ 0037 } 0038 qint64 firstByte() const override { 0039 return 0; /**< @return 0 for file */ 0040 } 0041 qint64 lastByte() const override { 0042 return length(); /**< @return equal to length for file. @see length() */ 0043 } 0044 QString path() const override { 0045 return m_File.fileName(); 0046 } 0047 0048 protected: 0049 QFile& file() { 0050 return m_File; 0051 } 0052 const QFile& file() const { 0053 return m_File; 0054 } 0055 0056 protected: 0057 QFile m_File; 0058 }; 0059 0060 #endif