aboutsummaryrefslogtreecommitdiff
path: root/launcher
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2022-10-15 15:24:30 +0200
committerGitHub <noreply@github.com>2022-10-15 15:24:30 +0200
commitc089f9b59f32780d3228d08c2d2eeb95e4ace9e1 (patch)
treeb31f8869425be0d16363b5fb461719dbf1826308 /launcher
parent924c1634d35e4e10222d12cb69ec11dd8b8af8ac (diff)
parent03d077e915cf2bf06474b17e51e0c664f57eb348 (diff)
downloadPrismLauncher-c089f9b59f32780d3228d08c2d2eeb95e4ace9e1.tar.gz
PrismLauncher-c089f9b59f32780d3228d08c2d2eeb95e4ace9e1.tar.bz2
PrismLauncher-c089f9b59f32780d3228d08c2d2eeb95e4ace9e1.zip
Merge pull request #1203 from DioEgizio/macos-legacy
Diffstat (limited to 'launcher')
-rw-r--r--launcher/CMakeLists.txt1
-rw-r--r--launcher/FileSystem.cpp31
2 files changed, 25 insertions, 7 deletions
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index c5894268..c7d0d68c 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -976,6 +976,7 @@ target_link_libraries(Launcher_logic
BuildConfig
Katabasis
Qt${QT_VERSION_MAJOR}::Widgets
+ ghcFilesystem::ghc_filesystem
)
if (UNIX AND NOT CYGWIN AND NOT APPLE)
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp
index 5d179641..c2db0dbc 100644
--- a/launcher/FileSystem.cpp
+++ b/launcher/FileSystem.cpp
@@ -59,7 +59,24 @@
#include <utime.h>
#endif
+// Snippet from https://github.com/gulrak/filesystem#using-it-as-single-file-header
+
+#ifdef __APPLE__
+#include <Availability.h> // for deployment target to support pre-catalina targets without std::fs
+#endif // __APPLE__
+
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include)
+#if __has_include(<filesystem>) && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
+#define GHC_USE_STD_FS
#include <filesystem>
+namespace fs = std::filesystem;
+#endif // MacOS min version check
+#endif // Other OSes version check
+
+#ifndef GHC_USE_STD_FS
+#include <ghc/filesystem.hpp>
+namespace fs = ghc::filesystem;
+#endif
#if defined Q_OS_WIN32
@@ -147,7 +164,7 @@ bool ensureFolderPathExists(QString foldernamepath)
bool copy::operator()(const QString& offset)
{
- using copy_opts = std::filesystem::copy_options;
+ using copy_opts = fs::copy_options;
// NOTE always deep copy on windows. the alternatives are too messy.
#if defined Q_OS_WIN32
@@ -159,7 +176,7 @@ bool copy::operator()(const QString& offset)
std::error_code err;
- std::filesystem::copy_options opt = copy_opts::none;
+ fs::copy_options opt = copy_opts::none;
// The default behavior is to follow symlinks
if (!m_followSymlinks)
@@ -182,7 +199,7 @@ bool copy::operator()(const QString& offset)
auto dst_path = PathCombine(dst, relative_path);
ensureFilePathExists(dst_path);
- std::filesystem::copy(toStdString(src_path), toStdString(dst_path), opt, err);
+ fs::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;
@@ -197,7 +214,7 @@ bool deletePath(QString path)
{
std::error_code err;
- std::filesystem::remove_all(toStdString(path), err);
+ fs::remove_all(toStdString(path), err);
if (err) {
qWarning() << "Failed to remove files:" << QString::fromStdString(err.message());
@@ -376,15 +393,15 @@ bool createShortCut(QString location, QString dest, QStringList args, QString na
bool overrideFolder(QString overwritten_path, QString override_path)
{
- using copy_opts = std::filesystem::copy_options;
+ using copy_opts = fs::copy_options;
if (!FS::ensureFolderPathExists(overwritten_path))
return false;
std::error_code err;
- std::filesystem::copy_options opt = copy_opts::recursive | copy_opts::overwrite_existing;
+ fs::copy_options opt = copy_opts::recursive | copy_opts::overwrite_existing;
- std::filesystem::copy(toStdString(override_path), toStdString(overwritten_path), opt, err);
+ fs::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);