mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 12:05:38 +00:00
Added a function to FileSystemUtil to return the ES-DE binary path
Also fixed an issue where the fallback to argv[0] in FileSystemUtil::setExePath() was not working correctly
This commit is contained in:
parent
923b6b2ed1
commit
15e5a8b305
|
@ -65,6 +65,7 @@ namespace Utils
|
|||
{
|
||||
static std::string homePath;
|
||||
static std::string exePath;
|
||||
static std::string esBinary;
|
||||
|
||||
StringList getDirContent(const std::string& path, const bool recursive)
|
||||
{
|
||||
|
@ -326,11 +327,15 @@ namespace Utils
|
|||
if (readlink("/proc/self/exe", &result[0], pathMax) != -1)
|
||||
exePath = result;
|
||||
#endif
|
||||
exePath.erase(std::find(exePath.begin(), exePath.end(), '\0'), exePath.end());
|
||||
esBinary = exePath;
|
||||
exePath = getCanonicalPath(exePath);
|
||||
|
||||
// Fallback to argv[0] if everything else fails.
|
||||
if (exePath.empty())
|
||||
if (exePath.empty()) {
|
||||
esBinary = path;
|
||||
exePath = getCanonicalPath(path);
|
||||
}
|
||||
if (isRegularFile(exePath))
|
||||
exePath = getParent(exePath);
|
||||
}
|
||||
|
@ -341,6 +346,12 @@ namespace Utils
|
|||
return exePath;
|
||||
}
|
||||
|
||||
std::string getEsBinary()
|
||||
{
|
||||
// Return the absolute path to the ES-DE binary.
|
||||
return esBinary;
|
||||
}
|
||||
|
||||
std::string getProgramDataPath()
|
||||
{
|
||||
#if defined(__unix__)
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace Utils
|
|||
std::string getPathToBinary(const std::string& executable);
|
||||
void setExePath(const std::string& path);
|
||||
std::string getExePath();
|
||||
std::string getEsBinary();
|
||||
std::string getProgramDataPath();
|
||||
std::string getPreferredPath(const std::string& path);
|
||||
std::string getGenericPath(const std::string& path);
|
||||
|
|
Loading…
Reference in a new issue