mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-19 23:17:21 -06:00
committed by
GitHub
parent
989b1e6c2c
commit
77aa85fbd3
@@ -292,6 +292,12 @@ bool Utils::Fs::isNetworkFileSystem(const Path &path)
|
||||
|
||||
bool Utils::Fs::copyFile(const Path &from, const Path &to)
|
||||
{
|
||||
if (!from.exists())
|
||||
return false;
|
||||
|
||||
if (!mkpath(to.parentPath()))
|
||||
return false;
|
||||
|
||||
return QFile::copy(from.data(), to.data());
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <QString>
|
||||
|
||||
#include "base/path.h"
|
||||
#include "base/utils/fs.h"
|
||||
|
||||
Utils::IO::FileDeviceOutputIterator::FileDeviceOutputIterator(QFileDevice &device, const int bufferSize)
|
||||
: m_device {&device}
|
||||
@@ -70,6 +71,8 @@ Utils::IO::FileDeviceOutputIterator &Utils::IO::FileDeviceOutputIterator::operat
|
||||
|
||||
nonstd::expected<void, QString> Utils::IO::saveToFile(const Path &path, const QByteArray &data)
|
||||
{
|
||||
if (const Path parentPath = path.parentPath(); !parentPath.isEmpty())
|
||||
Utils::Fs::mkpath(parentPath);
|
||||
QSaveFile file {path.data()};
|
||||
if (!file.open(QIODevice::WriteOnly) || (file.write(data) != data.size()) || !file.flush() || !file.commit())
|
||||
return nonstd::make_unexpected(file.errorString());
|
||||
|
||||
Reference in New Issue
Block a user