kpmcore/src/core/copysourceshred.h

65 lines
1.5 KiB
C
Raw Normal View History

/*
SPDX-FileCopyrightText: 2010 Volker Lanz <vl@fidra.de>
SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org>
SPDX-FileCopyrightText: 2016-2018 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2018 Huzaifa Faruqui <huzaifafaruqui@gmail.com>
SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef KPMCORE_COPYSOURCESHRED_H
#define KPMCORE_COPYSOURCESHRED_H
2016-05-06 22:36:24 +01:00
#include "core/copysource.h"
#include <QFile>
class CopyTarget;
class QString;
/** A source for securely overwriting a partition (shredding).
2015-07-13 15:16:36 +01:00
Represents a source of data (random or zeros) to copy from. Used to securely overwrite data on disk.
2015-07-13 15:16:36 +01:00
@author Volker Lanz <vl@fidra.de>
*/
class CopySourceShred : public CopySource
{
2015-07-13 15:16:36 +01:00
public:
CopySourceShred(qint64 size, bool randomShred);
2015-07-13 15:16:36 +01:00
public:
2016-05-17 18:01:31 +01:00
bool open() override;
qint64 length() const override;
2015-07-13 15:16:36 +01:00
2016-05-17 18:01:31 +01:00
bool overlaps(const CopyTarget&) const override {
2015-07-13 15:16:36 +01:00
return false; /**< @return false for shred source */
}
qint64 firstByte() const override {
2015-07-13 15:16:36 +01:00
return 0; /**< @return 0 for shred source */
}
qint64 lastByte() const override {
2015-07-13 15:16:36 +01:00
return length(); /**< @return equal to length for shred source. @see length() */
}
QString path() const override {
return m_SourceFile.fileName();
}
2015-07-13 15:16:36 +01:00
protected:
QFile& sourceFile() {
return m_SourceFile;
}
const QFile& sourceFile() const {
return m_SourceFile;
}
2017-09-11 12:01:39 +01:00
qint64 size() const {
2015-07-13 15:16:36 +01:00
return m_Size;
}
private:
qint64 m_Size;
QFile m_SourceFile;
};
#endif