From 67b372c1945483f27060a5b66343e7c671f7e75c Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Mon, 1 Jan 2024 15:01:48 +0100 Subject: [PATCH] SporeModManager: fix Path::GetAbsolutePath() for mingw --- SporeModManager/SporeModManagerHelpers/Path.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/SporeModManager/SporeModManagerHelpers/Path.cpp b/SporeModManager/SporeModManagerHelpers/Path.cpp index d691866..9b2db1a 100644 --- a/SporeModManager/SporeModManagerHelpers/Path.cpp +++ b/SporeModManager/SporeModManagerHelpers/Path.cpp @@ -126,6 +126,16 @@ std::filesystem::path Path::GetAbsolutePath(std::filesystem::path path) } catch (...) { + // mingw has weird behavior with std::filesystem::canonical(), + // it throws an exception even though the relative path exists, + // so to workaround that, we'll check if the fullPath exists and + // return that +#ifdef __MINGW32__ + if (std::filesystem::is_directory(fullPath)) + { + return fullPath; + } +#endif // just return the original path, // because the directory probably doesn't exist return path;