mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Added %EMUPATH% logic for Unix.
This commit is contained in:
parent
31da561695
commit
3cad68be13
|
@ -24,6 +24,7 @@
|
|||
#include "Window.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <filesystem>
|
||||
|
||||
FileData::FileData(
|
||||
FileType type,
|
||||
|
@ -516,7 +517,8 @@ void FileData::launchGame(Window* window)
|
|||
}
|
||||
}
|
||||
#else
|
||||
// TODO for Unix.
|
||||
std::string exePath = Utils::FileSystem::getPathToBinary(emuExecutable);
|
||||
command = Utils::String::replace(command, "%EMUPATH%", exePath);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -176,6 +176,26 @@ namespace Utils
|
|||
#endif
|
||||
}
|
||||
|
||||
std::string getPathToBinary(const std::string& executable)
|
||||
{
|
||||
#ifdef _WIN64
|
||||
return "";
|
||||
#else
|
||||
std::string pathVariable = std::string(getenv("PATH"));
|
||||
std::vector<std::string> pathList =
|
||||
Utils::String::delimitedStringToVector(pathVariable, ":");
|
||||
|
||||
std::string pathTest;
|
||||
|
||||
for (auto it = pathList.cbegin(); it != pathList.cend(); it++) {
|
||||
pathTest = it->c_str() + ("/" + executable);
|
||||
if (exists(pathTest))
|
||||
return it->c_str();
|
||||
}
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
void setExePath(const std::string& _path)
|
||||
{
|
||||
constexpr int path_max = 32767;
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace Utils
|
|||
void setHomePath(const std::string& _path);
|
||||
std::string getHomePath();
|
||||
std::string getCWDPath();
|
||||
std::string getPathToBinary(const std::string& executable);
|
||||
void setExePath(const std::string& _path);
|
||||
std::string getExePath();
|
||||
std::string getProgramDataPath();
|
||||
|
|
Loading…
Reference in a new issue