File indexing completed on 2024-04-28 05:45:44

0001 /*
0002     SPDX-FileCopyrightText: 2008 Volker Lanz <vl@fidra.de>
0003     SPDX-FileCopyrightText: 2008 Laurent Montel <montel@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_COPYTARGET_H
0011 #define KPMCORE_COPYTARGET_H
0012 
0013 #include <QtGlobal>
0014 
0015 class QString;
0016 
0017 /** Base class for something to copy to.
0018 
0019     Abstract base class for all copy targets. Used together with CopySource to
0020     implement moving, copying, restoring and backing up FileSystems.
0021 
0022     @see CopySource
0023     @author Volker Lanz <vl@fidra.de>
0024 */
0025 class CopyTarget
0026 {
0027     Q_DISABLE_COPY(CopyTarget)
0028 
0029 protected:
0030     CopyTarget() : m_BytesWritten(0) {}
0031     virtual ~CopyTarget() {}
0032 
0033 public:
0034     virtual bool open() = 0;
0035     virtual qint64 firstByte() const = 0;
0036     virtual qint64 lastByte() const = 0;
0037     virtual QString path() const = 0;
0038     qint64 bytesWritten() const {
0039         return m_BytesWritten;
0040     }
0041 
0042 protected:
0043     void setBytesWritten(qint64 s) {
0044         m_BytesWritten = s;
0045     }
0046 
0047 private:
0048     qint64 m_BytesWritten;
0049 };
0050 
0051 #endif