mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
commit
6f38784b5f
|
@ -36,9 +36,9 @@ bool parseArgs(int argc, char* argv[])
|
|||
// We need to process --home before any call to Settings::getInstance(), because settings are loaded from homepath
|
||||
for(int i = 1; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "--home") == 0)
|
||||
if(strcmp(argv[i], "--home") == 0)
|
||||
{
|
||||
if (i >= argc - 1)
|
||||
if(i >= argc - 1)
|
||||
{
|
||||
std::cerr << "Invalid home path supplied.";
|
||||
return false;
|
||||
|
|
|
@ -357,6 +357,10 @@ bool GuiInputConfig::filterTrigger(Input input, InputConfig* config, int inputId
|
|||
mSkipAxis = true;
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
(void)input;
|
||||
(void)config;
|
||||
(void)inputId;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
|
|
|
@ -25,8 +25,8 @@ namespace Utils
|
|||
{
|
||||
namespace FileSystem
|
||||
{
|
||||
static std::string homePath;
|
||||
static std::string exePath;
|
||||
static std::string homePath = "";
|
||||
static std::string exePath = "";
|
||||
|
||||
#if defined(_WIN32)
|
||||
static std::string convertFromWideString(const std::wstring wstring)
|
||||
|
@ -142,18 +142,20 @@ namespace Utils
|
|||
void setHomePath(const std::string& _path)
|
||||
{
|
||||
homePath = getGenericPath(_path);
|
||||
}
|
||||
|
||||
} // setHomePath
|
||||
|
||||
std::string getHomePath()
|
||||
{
|
||||
// only construct the homepath once
|
||||
if(homePath.length())
|
||||
return homePath;
|
||||
|
||||
// Is it a portable installation ? Check if ".emulationstation/es_systems.cfg" exists in the exe's path
|
||||
// check if "getExePath()/.emulationstation/es_systems.cfg" exists
|
||||
if(Utils::FileSystem::exists(getExePath() + "/.emulationstation/es_systems.cfg"))
|
||||
homePath = getExePath();
|
||||
|
||||
// Check for HOME environment variable
|
||||
// check for HOME environment variable
|
||||
if(!homePath.length())
|
||||
{
|
||||
char* envHome = getenv("HOME");
|
||||
|
@ -162,8 +164,7 @@ namespace Utils
|
|||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
// On Windows, HOME is not the system's user path but a user environment variable.
|
||||
// Instead we get the home user's path using %HOMEDRIVE%/%HOMEPATH% which are system variables.
|
||||
// on Windows we need to check HOMEDRIVE and HOMEPATH
|
||||
if(!homePath.length())
|
||||
{
|
||||
char* envHomeDrive = getenv("HOMEDRIVE");
|
||||
|
@ -193,15 +194,16 @@ namespace Utils
|
|||
|
||||
void setExePath(const std::string& _path)
|
||||
{
|
||||
std::string path = getCanonicalPath(_path);
|
||||
if(isRegularFile(path))
|
||||
path = getParent(path);
|
||||
exePath = getCanonicalPath(_path);
|
||||
|
||||
if(isRegularFile(exePath))
|
||||
exePath = getParent(exePath);
|
||||
|
||||
exePath = path;
|
||||
} // setExePath
|
||||
|
||||
std::string getExePath()
|
||||
{
|
||||
// return constructed exepath
|
||||
return exePath;
|
||||
|
||||
} // getExePath
|
||||
|
@ -451,22 +453,18 @@ namespace Utils
|
|||
bool contains = false;
|
||||
std::string path = removeCommonPath(_path, _relativeTo, contains);
|
||||
|
||||
if(contains)
|
||||
{
|
||||
// success
|
||||
if(contains)
|
||||
return ("./" + path);
|
||||
}
|
||||
|
||||
if(_allowHome)
|
||||
{
|
||||
path = removeCommonPath(_path, getHomePath(), contains);
|
||||
|
||||
if(contains)
|
||||
{
|
||||
// success
|
||||
if(contains)
|
||||
return ("~/" + path);
|
||||
}
|
||||
}
|
||||
|
||||
// nothing to resolve
|
||||
return path;
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace Utils
|
|||
bool isDirectory (const std::string& _path);
|
||||
bool isSymlink (const std::string& _path);
|
||||
bool isHidden (const std::string& _path);
|
||||
|
||||
} // FileSystem::
|
||||
|
||||
} // Utils::
|
||||
|
|
|
@ -205,7 +205,7 @@ namespace Utils
|
|||
{
|
||||
done = true;
|
||||
|
||||
for(int i = 0; i < sizeof(remove); i += 2)
|
||||
for(size_t i = 0; i < sizeof(remove); i += 2)
|
||||
{
|
||||
end = string.find_first_of(remove[i + 1]);
|
||||
start = string.find_last_of( remove[i + 0], end);
|
||||
|
@ -280,14 +280,13 @@ namespace Utils
|
|||
|
||||
} // format
|
||||
|
||||
// Simple XOR scrambling of a string, with an accompanying key
|
||||
std::string scramble(const std::string& _input, const std::string& key)
|
||||
std::string scramble(const std::string& _input, const std::string& _key)
|
||||
{
|
||||
std::string buffer = _input;
|
||||
|
||||
for (size_t i = 0; i < _input.size(); ++i)
|
||||
for(size_t i = 0; i < _input.size(); ++i)
|
||||
{
|
||||
buffer[i] = _input[i] ^ key[i];
|
||||
buffer[i] = _input[i] ^ _key[i];
|
||||
}
|
||||
|
||||
return buffer;
|
||||
|
|
Loading…
Reference in a new issue