diff --git a/common/Path.h b/common/Path.h index a6858dd710..90738b95ae 100644 --- a/common/Path.h +++ b/common/Path.h @@ -18,6 +18,10 @@ #include #include "common/StringHelpers.h" +#include "ghc/filesystem.h" + +namespace fs = ghc::filesystem; + #define g_MaxPath 255 // 255 is safer with antiquated Win32 ASCII APIs. // -------------------------------------------------------------------------------------- @@ -233,4 +237,5 @@ namespace Path extern wxString GetDirectory(const wxString& src); extern wxString GetFilenameWithoutExt(const wxString& src); extern wxString GetRootDirectory(const wxString& src); + extern fs::path FromWxString(const wxString& path); } // namespace Path diff --git a/common/PathUtils.cpp b/common/PathUtils.cpp index a95f30a2c6..083ec927df 100644 --- a/common/PathUtils.cpp +++ b/common/PathUtils.cpp @@ -195,7 +195,6 @@ wxString Path::GetDirectory(const wxString& src) return wxFileName(src).GetPath(); } - // returns the base/root directory of the given path. // Example /this/that/something.txt -> dest == "/" wxString Path::GetRootDirectory(const wxString& src) @@ -206,3 +205,12 @@ wxString Path::GetRootDirectory(const wxString& src) else return wxString(src.begin(), src.begin() + pos); } + +fs::path Path::FromWxString(const wxString& path) +{ +#ifdef _WIN32 + return fs::path(path.ToStdWstring()); +#else + return fs::path(path.ToStdString()); +#endif +} \ No newline at end of file