aboutsummaryrefslogtreecommitdiff
path: root/launcher/FileSystem.cpp
diff options
context:
space:
mode:
authorRachel Powers <508861+Ryex@users.noreply.github.com>2022-12-29 17:21:54 -0700
committerRachel Powers <508861+Ryex@users.noreply.github.com>2022-12-29 17:21:54 -0700
commitc470f05abf090232b27faac6014f9e1cbe9dab9b (patch)
tree6dcca30406fb8bf97a4ee4f3a09c9143230a40d1 /launcher/FileSystem.cpp
parent3691f3a2963c77dbd7b469b4b90ca79b61014d43 (diff)
downloadPrismLauncher-c470f05abf090232b27faac6014f9e1cbe9dab9b.tar.gz
PrismLauncher-c470f05abf090232b27faac6014f9e1cbe9dab9b.tar.bz2
PrismLauncher-c470f05abf090232b27faac6014f9e1cbe9dab9b.zip
refactor: use std::filesystem::rename insted of copy and then moving.
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Diffstat (limited to 'launcher/FileSystem.cpp')
-rw-r--r--launcher/FileSystem.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp
index 3e8e10a5..4390eed9 100644
--- a/launcher/FileSystem.cpp
+++ b/launcher/FileSystem.cpp
@@ -213,6 +213,22 @@ bool copy::operator()(const QString& offset, bool dryRun)
return err.value() == 0;
}
+bool move(const QString& source, const QString& dest)
+{
+ std::error_code err;
+
+ ensureFilePathExists(dest);
+ fs::rename(StringUtils::toStdString(source), StringUtils::toStdString(dest), err);
+
+ if (err) {
+ qWarning() << "Failed to move file:" << QString::fromStdString(err.message());
+ qDebug() << "Source file:" << source;
+ qDebug() << "Destination file:" << dest;
+ }
+
+ return err.value() == 0;
+}
+
bool deletePath(QString path)
{
std::error_code err;