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