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

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

View file

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

View file

@ -62,12 +62,12 @@ namespace Renderer
}; // Vertex }; // Vertex
bool init (); bool init ();
void deinit (); void deinit ();
void pushClipRect (const Vector2i& _pos, const Vector2i& _size); void pushClipRect (const Vector2i& _pos, const Vector2i& _size);
void popClipRect (); void popClipRect ();
void drawRect (const float _x, const float _y, const float _w, const float _h, const unsigned int _color, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA); void drawRect (const float _x, const float _y, const float _w, const float _h, const unsigned int _color, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
void drawRect (const int _x, const int _y, const int _w, const int _h, const unsigned int _color, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA); void drawRect (const int _x, const int _y, const int _w, const int _h, const unsigned int _color, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
SDL_Window* getSDLWindow (); SDL_Window* getSDLWindow ();
int getWindowWidth (); int getWindowWidth ();

View file

@ -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,21 +453,17 @@ namespace Utils
bool contains = false; bool contains = false;
std::string path = removeCommonPath(_path, _relativeTo, contains); std::string path = removeCommonPath(_path, _relativeTo, contains);
// success
if(contains) if(contains)
{
// success
return ("./" + path); return ("./" + path);
}
if(_allowHome) if(_allowHome)
{ {
path = removeCommonPath(_path, getHomePath(), contains); path = removeCommonPath(_path, getHomePath(), contains);
// success
if(contains) if(contains)
{
// success
return ("~/" + path); return ("~/" + path);
}
} }
// nothing to resolve // nothing to resolve

View file

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

View file

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