diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2022-10-22 23:36:47 +0200 |
---|---|---|
committer | Sefa Eyeoglu <contact@scrumplex.net> | 2022-11-12 20:28:29 +0100 |
commit | 15aaff7c1ce8d709c444d891bf640ee39494d10e (patch) | |
tree | 8a2943a5ac0dc57fc5ec59131907c275c174113d /launcher/FileSystem.cpp | |
parent | e048bce13ea4bd56ef96ba7a1a4699142d09600a (diff) | |
download | PrismLauncher-15aaff7c1ce8d709c444d891bf640ee39494d10e.tar.gz PrismLauncher-15aaff7c1ce8d709c444d891bf640ee39494d10e.tar.bz2 PrismLauncher-15aaff7c1ce8d709c444d891bf640ee39494d10e.zip |
feat: add dryRun to copy operation
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Diffstat (limited to 'launcher/FileSystem.cpp')
-rw-r--r-- | launcher/FileSystem.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index a3b9fe1f..06691fbf 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -152,9 +152,10 @@ bool ensureFolderPathExists(QString foldernamepath) /// @brief Copies a directory and it's contents from src to dest /// @param offset subdirectory form src to copy to dest /// @return if there was an error during the filecopy -bool copy::operator()(const QString& offset) +bool copy::operator()(const QString& offset, bool dryRun) { using copy_opts = fs::copy_options; + m_copied = 0; // reset counter // NOTE always deep copy on windows. the alternatives are too messy. #if defined Q_OS_WIN32 @@ -178,9 +179,10 @@ bool copy::operator()(const QString& offset) return; auto dst_path = PathCombine(dst, relative_dst_path); - ensureFilePathExists(dst_path); - - fs::copy(StringUtils::toStdString(src_path), StringUtils::toStdString(dst_path), opt, err); + if (!dryRun) { + ensureFilePathExists(dst_path); + fs::copy(StringUtils::toStdString(src_path), StringUtils::toStdString(dst_path), opt, err); + } if (err) { qWarning() << "Failed to copy files:" << QString::fromStdString(err.message()); qDebug() << "Source file:" << src_path; |