mirror of https://github.com/PCSX2/pcsx2.git
common: add some file-path helpers to `Path` ns
This commit is contained in:
parent
6920b4e366
commit
85bd8555c0
|
@ -18,6 +18,10 @@
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
#include "common/StringHelpers.h"
|
#include "common/StringHelpers.h"
|
||||||
|
|
||||||
|
#include "ghc/filesystem.h"
|
||||||
|
|
||||||
|
namespace fs = ghc::filesystem;
|
||||||
|
|
||||||
#define g_MaxPath 255 // 255 is safer with antiquated Win32 ASCII APIs.
|
#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 GetDirectory(const wxString& src);
|
||||||
extern wxString GetFilenameWithoutExt(const wxString& src);
|
extern wxString GetFilenameWithoutExt(const wxString& src);
|
||||||
extern wxString GetRootDirectory(const wxString& src);
|
extern wxString GetRootDirectory(const wxString& src);
|
||||||
|
extern fs::path FromWxString(const wxString& path);
|
||||||
} // namespace Path
|
} // namespace Path
|
||||||
|
|
|
@ -195,7 +195,6 @@ wxString Path::GetDirectory(const wxString& src)
|
||||||
return wxFileName(src).GetPath();
|
return wxFileName(src).GetPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// returns the base/root directory of the given path.
|
// returns the base/root directory of the given path.
|
||||||
// Example /this/that/something.txt -> dest == "/"
|
// Example /this/that/something.txt -> dest == "/"
|
||||||
wxString Path::GetRootDirectory(const wxString& src)
|
wxString Path::GetRootDirectory(const wxString& src)
|
||||||
|
@ -206,3 +205,12 @@ wxString Path::GetRootDirectory(const wxString& src)
|
||||||
else
|
else
|
||||||
return wxString(src.begin(), src.begin() + pos);
|
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
|
||||||
|
}
|
Loading…
Reference in New Issue