1 /*
2     SPDX-FileCopyrightText: 2008 Volker Lanz <vl@fidra.de>
3     SPDX-FileCopyrightText: 2014-2018 Andrius Štikonas <andrius@stikonas.eu>
4     SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org>
5 
6     SPDX-License-Identifier: GPL-3.0-or-later
7 */
8 
9 #include "core/copysourceshred.h"
10 
11 /** Constructs a CopySourceShred with the given @p size
12     @param s the size the copy source will (pretend to) have
13 */
CopySourceShred(qint64 s,bool randomShred)14 CopySourceShred::CopySourceShred(qint64 s, bool randomShred) :
15     CopySource(),
16     m_Size(s),
17     m_SourceFile(randomShred ? QStringLiteral("/dev/urandom") : QStringLiteral("/dev/zero"))
18 {
19 }
20 
21 /** Opens the shred source.
22     @return true on success
23 */
open()24 bool CopySourceShred::open()
25 {
26     return sourceFile().open(QIODevice::ReadOnly);
27 }
28 
29 /** Returns the length of the source in bytes.
30     @return length of the source in bytes.
31 */
length() const32 qint64 CopySourceShred::length() const
33 {
34     return size();
35 }
36