Merge pull request #593 from tomaz82/cleanup

Automn cleaning
This commit is contained in:
John Rassa 2019-08-25 13:50:37 -04:00 committed by GitHub
commit 6f38784b5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
89 changed files with 318 additions and 316 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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::

View file

@ -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)
{
buffer[i] = _input[i] ^ key[i];
buffer[i] = _input[i] ^ _key[i];
}
return buffer;