diff options
author | flow <flowlnlnln@gmail.com> | 2022-08-07 14:30:38 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-09-12 13:07:24 -0300 |
commit | ee0fb2d0e00bba8c000a277d5f7199ae46a095df (patch) | |
tree | b100c09b0b2dc57881facf678d044e4e94a18430 | |
parent | c496ad1237198cf9c5a97b3b02c2897b5ac1990a (diff) | |
download | PrismLauncher-ee0fb2d0e00bba8c000a277d5f7199ae46a095df.tar.gz PrismLauncher-ee0fb2d0e00bba8c000a277d5f7199ae46a095df.tar.bz2 PrismLauncher-ee0fb2d0e00bba8c000a277d5f7199ae46a095df.zip |
fix: use std::wstring for Windows filenames
Signed-off-by: flow <flowlnlnln@gmail.com>
-rw-r--r-- | launcher/FileSystem.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 2409696b..5d179641 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -61,6 +61,22 @@ #include <filesystem> +#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) @@ -166,7 +182,7 @@ bool copy::operator()(const QString& offset) auto dst_path = PathCombine(dst, relative_path); ensureFilePathExists(dst_path); - std::filesystem::copy(src_path.toStdString(), dst_path.toStdString(), opt, err); + std::filesystem::copy(toStdString(src_path), toStdString(dst_path), opt, err); if (err) { qWarning() << "Failed to copy files:" << QString::fromStdString(err.message()); qDebug() << "Source file:" << src_path; @@ -181,7 +197,7 @@ bool deletePath(QString path) { std::error_code err; - std::filesystem::remove_all(path.toStdString(), err); + std::filesystem::remove_all(toStdString(path), err); if (err) { qWarning() << "Failed to remove files:" << QString::fromStdString(err.message()); @@ -368,7 +384,7 @@ bool overrideFolder(QString overwritten_path, QString override_path) std::error_code err; std::filesystem::copy_options opt = copy_opts::recursive | copy_opts::overwrite_existing; - std::filesystem::copy(override_path.toStdString(), overwritten_path.toStdString(), opt, err); + std::filesystem::copy(toStdString(override_path), toStdString(overwritten_path), opt, err); if (err) { qCritical() << QString("Failed to apply override from %1 to %2").arg(override_path, overwritten_path); |