aboutsummaryrefslogtreecommitdiff
path: root/launcher/FileSystem.cpp
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2022-11-10 14:34:15 +0100
committerGitHub <noreply@github.com>2022-11-10 14:34:15 +0100
commit392452d422be517b82fd4cc35087b44df16fc3f7 (patch)
tree2696a095e889a6bab49de4dc95f78ce81c7e97a6 /launcher/FileSystem.cpp
parente6d057fe6da1209b85af2e8385a5c1251af7e8d4 (diff)
parent9ad6eb11a37815f7aab89163184d519a2183f4f2 (diff)
downloadPrismLauncher-392452d422be517b82fd4cc35087b44df16fc3f7.tar.gz
PrismLauncher-392452d422be517b82fd4cc35087b44df16fc3f7.tar.bz2
PrismLauncher-392452d422be517b82fd4cc35087b44df16fc3f7.zip
Merge pull request #397 from flowln/windows_mod_updater_fixes_maybe
Fixes https://github.com/PrismLauncher/PrismLauncher/issues/226
Diffstat (limited to 'launcher/FileSystem.cpp')
-rw-r--r--launcher/FileSystem.cpp26
1 files changed, 6 insertions, 20 deletions
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp
index 4026d6c1..1cbb538c 100644
--- a/launcher/FileSystem.cpp
+++ b/launcher/FileSystem.cpp
@@ -44,7 +44,9 @@
#include <QStandardPaths>
#include <QTextStream>
#include <QUrl>
+
#include "DesktopServices.h"
+#include "StringUtils.h"
#if defined Q_OS_WIN32
#include <objbase.h>
@@ -79,22 +81,6 @@ namespace fs = std::filesystem;
namespace fs = ghc::filesystem;
#endif
-#if defined Q_OS_WIN32
-
-std::wstring toStdString(QString s)
-{
- return s.toStdWString();
-}
-
-#else
-
-std::string toStdString(QString s)
-{
- return s.toStdString();
-}
-
-#endif
-
namespace FS {
void ensureExists(const QDir& dir)
@@ -191,7 +177,7 @@ bool copy::operator()(const QString& offset)
auto dst_path = PathCombine(dst, relative_dst_path);
ensureFilePathExists(dst_path);
- fs::copy(toStdString(src_path), toStdString(dst_path), opt, err);
+ 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;
@@ -213,7 +199,7 @@ bool copy::operator()(const QString& offset)
}
// If the root src is not a directory, the previous iterator won't run.
- if (!fs::is_directory(toStdString(src)))
+ if (!fs::is_directory(StringUtils::toStdString(src)))
copy_file(src, "");
return err.value() == 0;
@@ -223,7 +209,7 @@ bool deletePath(QString path)
{
std::error_code err;
- fs::remove_all(toStdString(path), err);
+ fs::remove_all(StringUtils::toStdString(path), err);
if (err) {
qWarning() << "Failed to remove files:" << QString::fromStdString(err.message());
@@ -414,7 +400,7 @@ bool overrideFolder(QString overwritten_path, QString override_path)
fs::copy_options opt = copy_opts::recursive | copy_opts::overwrite_existing;
// FIXME: hello traveller! Apparently std::copy does NOT overwrite existing files on GNU libstdc++ on Windows?
- fs::copy(toStdString(override_path), toStdString(overwritten_path), opt, err);
+ fs::copy(StringUtils::toStdString(override_path), StringUtils::toStdString(overwritten_path), opt, err);
if (err) {
qCritical() << QString("Failed to apply override from %1 to %2").arg(override_path, overwritten_path);