Implement class for handling filesystem paths

PR #15915.
This commit is contained in:
Vladimir Golovnev
2022-02-08 06:03:48 +03:00
committed by GitHub
parent facfa26eed
commit dd1bd8ad10
131 changed files with 2252 additions and 1868 deletions

View File

@@ -31,7 +31,7 @@
#include "settingvalue.h"
#include "utils/fs.h"
FileGuard::FileGuard(const QString &path)
FileGuard::FileGuard(const Path &path)
: m_path {path}
, m_remove {true}
{
@@ -45,17 +45,17 @@ void FileGuard::setAutoRemove(const bool remove) noexcept
FileGuard::~FileGuard()
{
if (m_remove && !m_path.isEmpty())
Utils::Fs::forceRemove(m_path); // forceRemove() checks for file existence
Utils::Fs::removeFile(m_path); // removeFile() checks for file existence
}
TorrentFileGuard::TorrentFileGuard(const QString &path, const TorrentFileGuard::AutoDeleteMode mode)
: FileGuard {mode != Never ? path : QString()}
TorrentFileGuard::TorrentFileGuard(const Path &path, const TorrentFileGuard::AutoDeleteMode mode)
: FileGuard {mode != Never ? path : Path()}
, m_mode {mode}
, m_wasAdded {false}
{
}
TorrentFileGuard::TorrentFileGuard(const QString &path)
TorrentFileGuard::TorrentFileGuard(const Path &path)
: TorrentFileGuard {path, autoDeleteMode()}
{
}