mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
(Windows) Added support for setting the root of a drive as the home folder.
This is mostly usable for portable installations, for example on a USB memory stick.
This commit is contained in:
parent
2b898981cb
commit
41c3c66eb7
|
@ -148,7 +148,12 @@ bool parseArgs(int argc, char* argv[])
|
|||
std::cerr << "Error: No home path supplied with \'--home'.\n";
|
||||
return false;
|
||||
}
|
||||
#ifdef _WIN64
|
||||
if (!Utils::FileSystem::exists(argv[i + 1]) &&
|
||||
(!Utils::FileSystem::driveExists(argv[i + 1]))) {
|
||||
#else
|
||||
if (!Utils::FileSystem::exists(argv[i + 1])) {
|
||||
#endif
|
||||
std::cerr << "Error: Home path \'" << argv[i + 1] << "\' does not exist.\n";
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -187,6 +187,8 @@ void Settings::setDefaults()
|
|||
mStringMap["SaveGamelistsMode"] = "always";
|
||||
#ifdef _WIN64
|
||||
mBoolMap["HideTaskbar"] = false;
|
||||
// Set this to true as default as it's unreliable to suspend ES during game launches
|
||||
// on some Windows versions/installations.
|
||||
mBoolMap["RunInBackground"] = true;
|
||||
#endif
|
||||
mStringMap["MediaDirectory"] = "";
|
||||
|
|
|
@ -706,6 +706,25 @@ namespace Utils
|
|||
#endif
|
||||
}
|
||||
|
||||
bool driveExists(const std::string& _path)
|
||||
{
|
||||
#ifdef _WIN64
|
||||
std::string path = getGenericPath(_path);
|
||||
// Try to add a dot or a backslash and a dot depending on how the drive
|
||||
// letter was defined by the user.
|
||||
if (path.length() == 2 && path.at(1) == ':')
|
||||
path += "\\.";
|
||||
else if (path.length() == 3 && path.at(1) == ':')
|
||||
path += ".";
|
||||
|
||||
struct _stat64 info;
|
||||
return (_wstat64(Utils::String::stringToWideString(path).c_str(), &info) == 0);
|
||||
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool isAbsolute(const std::string& _path)
|
||||
{
|
||||
std::string path = getGenericPath(_path);
|
||||
|
|
|
@ -55,6 +55,7 @@ namespace Utils
|
|||
|
||||
bool createDirectory(const std::string& _path);
|
||||
bool exists(const std::string& _path);
|
||||
bool driveExists(const std::string& _path);
|
||||
bool isAbsolute(const std::string& _path);
|
||||
bool isRegularFile(const std::string& _path);
|
||||
bool isDirectory(const std::string& _path);
|
||||
|
|
Loading…
Reference in a new issue