2020-09-20 20:33:16 +01:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2008 Volker Lanz <vl@fidra.de>
|
|
|
|
SPDX-FileCopyrightText: 2014-2018 Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2015-06-04 01:29:22 +01:00
|
|
|
|
|
|
|
#include "core/copysourcefile.h"
|
|
|
|
|
|
|
|
#include <QFile>
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
|
|
|
/** Constructs a CopySourceFile from the given @p filename.
|
2015-07-13 15:16:36 +01:00
|
|
|
@param filename filename of the file to copy from
|
2015-06-04 01:29:22 +01:00
|
|
|
*/
|
2017-10-26 16:20:21 +01:00
|
|
|
CopySourceFile::CopySourceFile(const QString& filename) :
|
2015-07-13 15:16:36 +01:00
|
|
|
CopySource(),
|
2017-10-26 16:20:21 +01:00
|
|
|
m_File(filename)
|
2015-06-04 01:29:22 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Opens the file.
|
2015-07-13 15:16:36 +01:00
|
|
|
@return true on success
|
2015-06-04 01:29:22 +01:00
|
|
|
*/
|
|
|
|
bool CopySourceFile::open()
|
|
|
|
{
|
2015-07-13 15:16:36 +01:00
|
|
|
return file().open(QIODevice::ReadOnly);
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
2017-10-26 16:20:21 +01:00
|
|
|
/** Returns the length of the file in bytes.
|
|
|
|
@return length of the file in bytes.
|
2015-06-04 01:29:22 +01:00
|
|
|
*/
|
|
|
|
qint64 CopySourceFile::length() const
|
|
|
|
{
|
2017-10-26 16:20:21 +01:00
|
|
|
return QFileInfo(file()).size();
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|