File indexing completed on 2024-05-05 05:48:39

0001 /*
0002     SPDX-FileCopyrightText: 2008 Volker Lanz <vl@fidra.de>
0003     SPDX-FileCopyrightText: 2014-2018 Andrius Štikonas <andrius@stikonas.eu>
0004     SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org>
0005 
0006     SPDX-License-Identifier: GPL-3.0-or-later
0007 */
0008 
0009 #include "core/copysourceshred.h"
0010 
0011 /** Constructs a CopySourceShred with the given @p size
0012     @param s the size the copy source will (pretend to) have
0013 */
0014 CopySourceShred::CopySourceShred(qint64 s, bool randomShred) :
0015     CopySource(),
0016     m_Size(s),
0017     m_SourceFile(randomShred ? QStringLiteral("/dev/urandom") : QStringLiteral("/dev/zero"))
0018 {
0019 }
0020 
0021 /** Opens the shred source.
0022     @return true on success
0023 */
0024 bool CopySourceShred::open()
0025 {
0026     return sourceFile().open(QIODevice::ReadOnly);
0027 }
0028 
0029 /** Returns the length of the source in bytes.
0030     @return length of the source in bytes.
0031 */
0032 qint64 CopySourceShred::length() const
0033 {
0034     return size();
0035 }