mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 01:25:38 +00:00
Removed some std::filesystem code
Also fixed an issue with launching emulators not defined via find rules
This commit is contained in:
parent
c3747d4e51
commit
116d73c62a
|
@ -211,14 +211,14 @@ void ApplicationUpdater::parseFile()
|
|||
#if (LOCAL_TESTING_FILE)
|
||||
LOG(LogWarning) << "ApplicationUpdater: Using local \"latest_release.json\" testing file";
|
||||
|
||||
const std::filesystem::path localReleaseFile {
|
||||
Utils::FileSystem::getAppDataDirectory().append("latest_release.json")};
|
||||
const std::string localReleaseFile {Utils::FileSystem::getAppDataDirectory() +
|
||||
"/latest_release.json"};
|
||||
|
||||
if (!Utils::FileSystem::existsSTD(localReleaseFile))
|
||||
if (!Utils::FileSystem::exists(localReleaseFile))
|
||||
throw std::runtime_error("Local testing file not found");
|
||||
|
||||
const ResourceData& localReleaseFileData {
|
||||
ResourceManager::getInstance().getFileData(localReleaseFile.string())};
|
||||
ResourceManager::getInstance().getFileData(localReleaseFile)};
|
||||
doc.Parse(reinterpret_cast<const char*>(localReleaseFileData.ptr.get()),
|
||||
localReleaseFileData.length);
|
||||
#else
|
||||
|
|
|
@ -1625,5 +1625,6 @@ std::string CollectionSystemsManager::getCustomCollectionConfigPath(
|
|||
|
||||
std::string CollectionSystemsManager::getCollectionsFolder()
|
||||
{
|
||||
return Utils::FileSystem::getAppDataDirectory().append("collections").string();
|
||||
return Utils::FileSystem::getGenericPath(Utils::FileSystem::getAppDataDirectory() +
|
||||
"/collections");
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ const std::vector<FileData*> FileData::getChildrenRecursive() const
|
|||
const std::string FileData::getROMDirectory()
|
||||
{
|
||||
#if defined(__ANDROID__)
|
||||
return AndroidVariables::sROMDirectory.string();
|
||||
return AndroidVariables::sROMDirectory;
|
||||
#endif
|
||||
|
||||
const std::string& romDirSetting {Settings::getInstance()->getString("ROMDirectory")};
|
||||
|
@ -189,8 +189,7 @@ const std::string FileData::getMediaDirectory()
|
|||
std::string mediaDirPath;
|
||||
|
||||
if (mediaDirSetting.empty()) {
|
||||
mediaDirPath =
|
||||
Utils::FileSystem::getAppDataDirectory().append("downloaded_media").string() + "/";
|
||||
mediaDirPath = Utils::FileSystem::getAppDataDirectory() + "/downloaded_media/";
|
||||
}
|
||||
else {
|
||||
mediaDirPath = mediaDirSetting;
|
||||
|
@ -879,8 +878,13 @@ void FileData::launchGame()
|
|||
}
|
||||
}
|
||||
else {
|
||||
LOG(LogDebug) << "FileData::launchGame(): Using default emulator \""
|
||||
<< mEnvData->mLaunchCommands.front().second << "\"";
|
||||
if (!mEnvData->mLaunchCommands.front().second.empty()) {
|
||||
LOG(LogDebug) << "FileData::launchGame(): Using default emulator \""
|
||||
<< mEnvData->mLaunchCommands.front().second << "\"";
|
||||
}
|
||||
else {
|
||||
LOG(LogDebug) << "FileData::launchGame(): Using default emulator";
|
||||
}
|
||||
}
|
||||
|
||||
if (command.empty())
|
||||
|
@ -2295,7 +2299,10 @@ const std::pair<std::string, FileData::findEmulatorResult> FileData::findEmulato
|
|||
}
|
||||
#endif
|
||||
|
||||
return std::make_pair(exePath, FileData::findEmulatorResult::NOT_FOUND);
|
||||
if (exePath.empty())
|
||||
return std::make_pair("", FileData::findEmulatorResult::NOT_FOUND);
|
||||
else
|
||||
return std::make_pair(exePath, FileData::findEmulatorResult::FOUND_FILE);
|
||||
}
|
||||
|
||||
CollectionFileData::CollectionFileData(FileData* file, SystemData* system)
|
||||
|
|
|
@ -468,10 +468,7 @@ void Screensaver::generateCustomImageList()
|
|||
Settings::getInstance()->getString("ScreensaverSlideshowCustomDir"))};
|
||||
|
||||
if (imageDir.empty())
|
||||
imageDir = Utils::FileSystem::getAppDataDirectory()
|
||||
.append("screensavers")
|
||||
.append("custom_slideshow")
|
||||
.string();
|
||||
imageDir = Utils::FileSystem::getAppDataDirectory() + "/screensavers/custom_slideshow";
|
||||
|
||||
// This makes it possible to set the custom image directory relative to the ES-DE binary
|
||||
// directory or the ROM directory.
|
||||
|
|
|
@ -41,11 +41,10 @@ FindRules::FindRules()
|
|||
|
||||
void FindRules::loadFindRules()
|
||||
{
|
||||
std::vector<std::filesystem::path> paths;
|
||||
std::filesystem::path filePath {Utils::FileSystem::getAppDataDirectory()
|
||||
.append("custom_systems")
|
||||
.append("es_find_rules.xml")};
|
||||
if (Utils::FileSystem::existsSTD(filePath)) {
|
||||
std::vector<std::string> paths;
|
||||
std::string filePath {Utils::FileSystem::getAppDataDirectory() +
|
||||
"/custom_systems/es_find_rules.xml"};
|
||||
if (Utils::FileSystem::exists(filePath)) {
|
||||
paths.emplace_back(filePath);
|
||||
LOG(LogInfo) << "Found custom find rules configuration file";
|
||||
}
|
||||
|
@ -78,17 +77,17 @@ void FindRules::loadFindRules()
|
|||
for (auto& path : paths) {
|
||||
#if defined(_WIN64)
|
||||
LOG(LogInfo) << "Parsing find rules configuration file \""
|
||||
<< Utils::String::replace(path.string(), "/", "\\") << "\"...";
|
||||
<< Utils::String::replace(path, "/", "\\") << "\"...";
|
||||
#else
|
||||
LOG(LogInfo) << "Parsing find rules configuration file \"" << path.string() << "\"...";
|
||||
LOG(LogInfo) << "Parsing find rules configuration file \"" << path << "\"...";
|
||||
#endif
|
||||
|
||||
pugi::xml_document doc;
|
||||
#if defined(_WIN64)
|
||||
const pugi::xml_parse_result& res {
|
||||
doc.load_file(Utils::String::stringToWideString(path.string()).c_str())};
|
||||
doc.load_file(Utils::String::stringToWideString(path).c_str())};
|
||||
#else
|
||||
const pugi::xml_parse_result& res {doc.load_file(path.string().c_str())};
|
||||
const pugi::xml_parse_result& res {doc.load_file(path.c_str())};
|
||||
#endif
|
||||
if (!res) {
|
||||
LOG(LogError) << "Couldn't parse es_find_rules.xml: " << res.description();
|
||||
|
@ -851,10 +850,9 @@ bool SystemData::loadConfig()
|
|||
void SystemData::loadSortingConfig()
|
||||
{
|
||||
const std::string sortSetting {Settings::getInstance()->getString("SystemsSorting")};
|
||||
const std::filesystem::path customFilePath {Utils::FileSystem::getAppDataDirectory()
|
||||
.append("custom_systems")
|
||||
.append("es_systems_sorting.xml")};
|
||||
const bool customFileExists {Utils::FileSystem::existsSTD(customFilePath)};
|
||||
const std::string customFilePath {Utils::FileSystem::getAppDataDirectory() +
|
||||
"/custom_systems/es_systems_sorting.xml"};
|
||||
const bool customFileExists {Utils::FileSystem::exists(customFilePath)};
|
||||
|
||||
std::string path;
|
||||
bool bundledFile {false};
|
||||
|
@ -885,7 +883,7 @@ void SystemData::loadSortingConfig()
|
|||
"bundled file has been selected";
|
||||
}
|
||||
else if (!bundledFile && customFileExists) {
|
||||
path = customFilePath.string();
|
||||
path = customFilePath;
|
||||
}
|
||||
|
||||
if (path.empty()) {
|
||||
|
@ -960,19 +958,18 @@ std::vector<std::string> SystemData::getConfigPath()
|
|||
{
|
||||
std::vector<std::string> paths;
|
||||
|
||||
const std::filesystem::path customSystemsDirectory {
|
||||
Utils::FileSystem::getAppDataDirectory().append("custom_systems")};
|
||||
const std::string customSystemsDirectory {Utils::FileSystem::getAppDataDirectory() +
|
||||
"/custom_systems"};
|
||||
|
||||
if (!Utils::FileSystem::existsSTD(customSystemsDirectory)) {
|
||||
LOG(LogInfo) << "Creating custom systems directory \"" << customSystemsDirectory.string()
|
||||
<< "\"...";
|
||||
Utils::FileSystem::createDirectory(customSystemsDirectory.string());
|
||||
if (!Utils::FileSystem::existsSTD(customSystemsDirectory)) {
|
||||
if (!Utils::FileSystem::exists(customSystemsDirectory)) {
|
||||
LOG(LogInfo) << "Creating custom systems directory \"" << customSystemsDirectory << "\"...";
|
||||
Utils::FileSystem::createDirectory(customSystemsDirectory);
|
||||
if (!Utils::FileSystem::exists(customSystemsDirectory)) {
|
||||
LOG(LogError) << "Couldn't create directory, permission problems?";
|
||||
}
|
||||
}
|
||||
|
||||
std::string path {customSystemsDirectory.string() + "/es_systems.xml"};
|
||||
std::string path {customSystemsDirectory + "/es_systems.xml"};
|
||||
|
||||
if (Utils::FileSystem::exists(path)) {
|
||||
LOG(LogInfo) << "Found custom systems configuration file";
|
||||
|
@ -1313,36 +1310,35 @@ SystemData* SystemData::getPrev() const
|
|||
|
||||
std::string SystemData::getGamelistPath(bool forWrite) const
|
||||
{
|
||||
std::filesystem::path filePath {mRootFolder->getPath() + "/gamelist.xml"};
|
||||
const std::filesystem::path gamelistPath {
|
||||
Utils::FileSystem::getAppDataDirectory().append("gamelists").append(mName)};
|
||||
std::string filePath {mRootFolder->getPath() + "/gamelist.xml"};
|
||||
const std::string gamelistPath {Utils::FileSystem::getAppDataDirectory() + "/gamelists/" +
|
||||
mName};
|
||||
|
||||
if (Utils::FileSystem::existsSTD(filePath)) {
|
||||
if (Utils::FileSystem::exists(filePath)) {
|
||||
if (Settings::getInstance()->getBool("LegacyGamelistFileLocation")) {
|
||||
return filePath.string();
|
||||
return filePath;
|
||||
}
|
||||
else {
|
||||
#if defined(_WIN64)
|
||||
LOG(LogWarning) << "Found a gamelist.xml file in \""
|
||||
<< Utils::String::replace(mRootFolder->getPath(), "/", "\\")
|
||||
<< "\\\" which will not get loaded, move it to \""
|
||||
<< gamelistPath.string() << "\\\" or otherwise delete it";
|
||||
<< "\\\" which will not get loaded, move it to \"" << gamelistPath
|
||||
<< "\\\" or otherwise delete it";
|
||||
#else
|
||||
LOG(LogWarning) << "Found a gamelist.xml file in \"" << mRootFolder->getPath()
|
||||
<< "/\" which will not get loaded, move it to \""
|
||||
<< gamelistPath.string() << "/\" or otherwise delete it";
|
||||
<< "/\" which will not get loaded, move it to \"" << gamelistPath
|
||||
<< "/\" or otherwise delete it";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
filePath = gamelistPath;
|
||||
filePath.append("gamelist.xml");
|
||||
filePath = gamelistPath + "/gamelist.xml";
|
||||
|
||||
// Make sure the directory exists if we're going to write to it, or crashes will happen.
|
||||
if (forWrite)
|
||||
Utils::FileSystem::createDirectory(Utils::FileSystem::getParent(filePath.string()));
|
||||
if (forWrite || Utils::FileSystem::existsSTD(filePath))
|
||||
return filePath.string();
|
||||
Utils::FileSystem::createDirectory(Utils::FileSystem::getParent(filePath));
|
||||
if (forWrite || Utils::FileSystem::exists(filePath))
|
||||
return filePath;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -1183,8 +1183,8 @@ void GuiMenu::openOtherOptions()
|
|||
rowMediaDir.addElement(bracketMediaDirectory, false);
|
||||
std::string titleMediaDir {"ENTER GAME MEDIA DIRECTORY"};
|
||||
std::string mediaDirectoryStaticText {"Default directory:"};
|
||||
std::string defaultDirectoryText {
|
||||
Utils::FileSystem::getAppDataDirectory().append("downloaded_media").string()};
|
||||
std::string defaultDirectoryText {Utils::FileSystem::getAppDataDirectory() +
|
||||
"/downloaded_media"};
|
||||
std::string initValueMediaDir {Settings::getInstance()->getString("MediaDirectory")};
|
||||
bool multiLineMediaDir {false};
|
||||
auto updateValMediaDir = [this](const std::string& newVal) {
|
||||
|
|
|
@ -210,10 +210,8 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions()
|
|||
rowCustomImageDir.addElement(bracketCustomImageDir, false);
|
||||
const std::string titleCustomImageDir {"CUSTOM IMAGE DIRECTORY"};
|
||||
const std::string defaultImageDirStaticText {"Default directory:"};
|
||||
const std::string defaultImageDirText {Utils::FileSystem::getAppDataDirectory()
|
||||
.append("screensavers")
|
||||
.append("custom_slideshow")
|
||||
.string()};
|
||||
const std::string defaultImageDirText {Utils::FileSystem::getAppDataDirectory() +
|
||||
"/screensavers/custom_slideshow"};
|
||||
const std::string initValueMediaDir {
|
||||
Settings::getInstance()->getString("ScreensaverSlideshowCustomDir")};
|
||||
auto updateValMediaDir = [s](const std::string& newVal) {
|
||||
|
|
|
@ -175,32 +175,30 @@ GuiThemeDownloader::GuiThemeDownloader(std::function<void()> updateCallback)
|
|||
mFuture = mPromise.get_future();
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
mThemeDirectory = Utils::FileSystem::getInternalAppDataDirectory().append("themes").string();
|
||||
mThemeDirectory = Utils::FileSystem::getInternalAppDataDirectory() + "/themes";
|
||||
#else
|
||||
const std::filesystem::path defaultUserThemeDir {
|
||||
Utils::FileSystem::getAppDataDirectory().append("themes")};
|
||||
const std::filesystem::path userThemeDirSetting {Utils::FileSystem::expandHomePath(
|
||||
const std::string defaultUserThemeDir {Utils::FileSystem::getAppDataDirectory() + "/themes"};
|
||||
const std::string userThemeDirSetting {Utils::FileSystem::expandHomePath(
|
||||
Settings::getInstance()->getString("UserThemeDirectory"))};
|
||||
|
||||
#if defined(_WIN64)
|
||||
mThemeDirectory = Utils::String::replace(mThemeDirectory, "\\", "/");
|
||||
#endif
|
||||
|
||||
if (userThemeDirSetting.empty()) {
|
||||
mThemeDirectory = defaultUserThemeDir.string();
|
||||
mThemeDirectory = defaultUserThemeDir;
|
||||
}
|
||||
else if (Utils::FileSystem::isDirectorySTD(userThemeDirSetting) ||
|
||||
Utils::FileSystem::isSymlinkSTD(userThemeDirSetting)) {
|
||||
mThemeDirectory = userThemeDirSetting.string();
|
||||
else if (Utils::FileSystem::isDirectory(userThemeDirSetting) ||
|
||||
Utils::FileSystem::isSymlink(userThemeDirSetting)) {
|
||||
mThemeDirectory = userThemeDirSetting;
|
||||
}
|
||||
else {
|
||||
LOG(LogWarning) << "GuiThemeDownloader: Requested user theme directory \""
|
||||
<< userThemeDirSetting.string()
|
||||
<< userThemeDirSetting
|
||||
<< "\" does not exist or is not a directory, reverting to \""
|
||||
<< defaultUserThemeDir.string() << "\"";
|
||||
mThemeDirectory = defaultUserThemeDir.string();
|
||||
<< defaultUserThemeDir << "\"";
|
||||
mThemeDirectory = defaultUserThemeDir;
|
||||
}
|
||||
#endif // __ANDROID__
|
||||
#endif
|
||||
|
||||
if (mThemeDirectory.back() != '/')
|
||||
mThemeDirectory.append("/");
|
||||
|
@ -593,8 +591,7 @@ void GuiThemeDownloader::parseThemesList()
|
|||
#if (LOCAL_TESTING_FILE)
|
||||
LOG(LogWarning) << "GuiThemeDownloader: Using local \"themes.json\" testing file";
|
||||
|
||||
const std::string themesFile {
|
||||
Utils::FileSystem::getAppDataDirectory().append("themes.json").string()};
|
||||
const std::string themesFile {Utils::FileSystem::getAppDataDirectory() + "/themes.json"};
|
||||
#else
|
||||
const std::string themesFile {mThemeDirectory + "themes-list/themes.json"};
|
||||
#endif
|
||||
|
@ -1191,15 +1188,15 @@ bool GuiThemeDownloader::input(InputConfig* config, Input input)
|
|||
"PROCEED",
|
||||
[this] {
|
||||
#if defined(_WIN64)
|
||||
const std::filesystem::path themeDirectory {
|
||||
const std::string themeDirectory {
|
||||
Utils::String::replace(mThemeDirectory, "/", "\\") +
|
||||
mThemes[mList->getCursorId()].reponame};
|
||||
#else
|
||||
const std::filesystem::path themeDirectory {mThemeDirectory +
|
||||
mThemes[mList->getCursorId()].reponame};
|
||||
const std::string themeDirectory {mThemeDirectory +
|
||||
mThemes[mList->getCursorId()].reponame};
|
||||
#endif
|
||||
LOG(LogInfo) << "Deleting theme directory \"" << themeDirectory.string() << "\"";
|
||||
if (!Utils::FileSystem::removeDirectory(themeDirectory.string(), true)) {
|
||||
LOG(LogInfo) << "Deleting theme directory \"" << themeDirectory << "\"";
|
||||
if (!Utils::FileSystem::removeDirectory(themeDirectory, true)) {
|
||||
mWindow->pushGui(new GuiMsgBox(
|
||||
getHelpStyle(), "COULDN'T DELETE THEME, PERMISSION PROBLEMS?", "OK",
|
||||
[] { return; }, "", nullptr, "", nullptr, nullptr, true));
|
||||
|
|
|
@ -444,18 +444,18 @@ bool parseArguments(const std::vector<std::string>& arguments)
|
|||
bool checkApplicationDataDirectory()
|
||||
{
|
||||
// Check that the application data directory exists, otherwise create it.
|
||||
const std::filesystem::path applicationData {Utils::FileSystem::getAppDataDirectory()};
|
||||
if (!Utils::FileSystem::existsSTD(applicationData)) {
|
||||
const std::string applicationData {Utils::FileSystem::getAppDataDirectory()};
|
||||
if (!Utils::FileSystem::exists(applicationData)) {
|
||||
#if defined(__ANDROID__)
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, ANDROID_APPLICATION_ID,
|
||||
"First startup, creating application data directory \"%s\"",
|
||||
applicationData.string().c_str());
|
||||
applicationData.c_str());
|
||||
#else
|
||||
std::cout << "First startup, creating application data directory \""
|
||||
<< applicationData.string() << "\"\n";
|
||||
std::cout << "First startup, creating application data directory \"" << applicationData
|
||||
<< "\"\n";
|
||||
#endif
|
||||
Utils::FileSystem::createDirectory(applicationData.string());
|
||||
if (!Utils::FileSystem::existsSTD(applicationData)) {
|
||||
Utils::FileSystem::createDirectory(applicationData);
|
||||
if (!Utils::FileSystem::exists(applicationData)) {
|
||||
#if defined(__ANDROID__)
|
||||
__android_log_print(ANDROID_LOG_ERROR, ANDROID_APPLICATION_ID,
|
||||
"Error: Couldn't create directory, permission problems?");
|
||||
|
@ -597,18 +597,16 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
if (!Settings::getInstance()->getBool("LegacyAppDataDirectory")) {
|
||||
// Create the logs folder in the application data directory.
|
||||
const std::filesystem::path logsDir {
|
||||
Utils::FileSystem::getAppDataDirectory().append("logs")};
|
||||
if (!Utils::FileSystem::isDirectorySTD(logsDir)) {
|
||||
const std::string logsDir {Utils::FileSystem::getAppDataDirectory() + "/logs"};
|
||||
if (!Utils::FileSystem::isDirectory(logsDir)) {
|
||||
#if defined(__ANDROID__)
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, ANDROID_APPLICATION_ID,
|
||||
"Creating logs directory \"%s\"...", logsDir.string().c_str());
|
||||
"Creating logs directory \"%s\"...", logsDir.c_str());
|
||||
#else
|
||||
std::cout << "Creating logs directory \"" << logsDir.string() << "\"..."
|
||||
<< std::endl;
|
||||
std::cout << "Creating logs directory \"" << logsDir << "\"..." << std::endl;
|
||||
#endif
|
||||
Utils::FileSystem::createDirectory(logsDir.string());
|
||||
if (!Utils::FileSystem::isDirectorySTD(logsDir)) {
|
||||
Utils::FileSystem::createDirectory(logsDir);
|
||||
if (!Utils::FileSystem::isDirectory(logsDir)) {
|
||||
#if defined(__ANDROID__)
|
||||
__android_log_print(ANDROID_LOG_ERROR, ANDROID_APPLICATION_ID,
|
||||
"Couldn't create directory, permission problems?");
|
||||
|
@ -618,10 +616,10 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
else {
|
||||
// Remove any old logs in the root of the directory.
|
||||
Utils::FileSystem::removeFile(
|
||||
Utils::FileSystem::getAppDataDirectory().append("es_log.txt").string());
|
||||
Utils::FileSystem::removeFile(
|
||||
Utils::FileSystem::getAppDataDirectory().append("es_log.txt.bak").string());
|
||||
Utils::FileSystem::removeFile(Utils::FileSystem::getAppDataDirectory() +
|
||||
"/es_log.txt");
|
||||
Utils::FileSystem::removeFile(Utils::FileSystem::getAppDataDirectory() +
|
||||
"/es_log.txt.bak");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -668,35 +666,30 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
if (!Settings::getInstance()->getBool("LegacyAppDataDirectory")) {
|
||||
// Create the settings folder in the application data directory.
|
||||
const std::filesystem::path settingsDir {
|
||||
Utils::FileSystem::getAppDataDirectory().append("settings")};
|
||||
if (!Utils::FileSystem::isDirectorySTD(settingsDir)) {
|
||||
LOG(LogInfo) << "Creating settings directory \"" << settingsDir.string() << "\"...";
|
||||
Utils::FileSystem::createDirectory(settingsDir.string());
|
||||
if (!Utils::FileSystem::isDirectorySTD(settingsDir)) {
|
||||
const std::string settingsDir {Utils::FileSystem::getAppDataDirectory() + "/settings"};
|
||||
if (!Utils::FileSystem::isDirectory(settingsDir)) {
|
||||
LOG(LogInfo) << "Creating settings directory \"" << settingsDir << "\"...";
|
||||
Utils::FileSystem::createDirectory(settingsDir);
|
||||
if (!Utils::FileSystem::isDirectory(settingsDir)) {
|
||||
LOG(LogError) << "Couldn't create directory, permission problems?";
|
||||
}
|
||||
}
|
||||
std::filesystem::path settingsPathOld;
|
||||
std::filesystem::path settingsPathNew;
|
||||
settingsPathOld = Utils::FileSystem::getAppDataDirectory().append("es_settings.xml");
|
||||
settingsPathNew = Utils::FileSystem::getAppDataDirectory()
|
||||
.append("settings")
|
||||
.append("es_settings.xml");
|
||||
if (!Utils::FileSystem::existsSTD(settingsPathNew) &&
|
||||
Utils::FileSystem::existsSTD(settingsPathOld)) {
|
||||
Utils::FileSystem::renameFile(settingsPathOld.string(), settingsPathNew.string(),
|
||||
false);
|
||||
std::string settingsPathOld;
|
||||
std::string settingsPathNew;
|
||||
settingsPathOld = Utils::FileSystem::getAppDataDirectory() + "/es_settings.xml";
|
||||
settingsPathNew =
|
||||
Utils::FileSystem::getAppDataDirectory() + "/settings/es_settings.xml";
|
||||
if (!Utils::FileSystem::exists(settingsPathNew) &&
|
||||
Utils::FileSystem::exists(settingsPathOld)) {
|
||||
Utils::FileSystem::renameFile(settingsPathOld, settingsPathNew, false);
|
||||
Settings::getInstance()->loadFile();
|
||||
migratedSettings = true;
|
||||
}
|
||||
settingsPathOld = Utils::FileSystem::getAppDataDirectory().append("es_input.xml");
|
||||
settingsPathNew =
|
||||
Utils::FileSystem::getAppDataDirectory().append("settings").append("es_input.xml");
|
||||
if (!Utils::FileSystem::existsSTD(settingsPathNew) &&
|
||||
Utils::FileSystem::existsSTD(settingsPathOld)) {
|
||||
Utils::FileSystem::renameFile(settingsPathOld.string(), settingsPathNew.string(),
|
||||
false);
|
||||
settingsPathOld = Utils::FileSystem::getAppDataDirectory() + "/es_input.xml";
|
||||
settingsPathNew = Utils::FileSystem::getAppDataDirectory() + "/settings/es_input.xml";
|
||||
if (!Utils::FileSystem::exists(settingsPathNew) &&
|
||||
Utils::FileSystem::exists(settingsPathOld)) {
|
||||
Utils::FileSystem::renameFile(settingsPathOld, settingsPathNew, false);
|
||||
migratedSettings = true;
|
||||
}
|
||||
}
|
||||
|
@ -704,15 +697,13 @@ int main(int argc, char* argv[])
|
|||
|
||||
{
|
||||
// Check if the es_settings.xml file exists, and if not, create it.
|
||||
std::filesystem::path settingsPath;
|
||||
std::string settingsPath;
|
||||
if (Settings::getInstance()->getBool("LegacyAppDataDirectory"))
|
||||
settingsPath = Utils::FileSystem::getAppDataDirectory().append("es_settings.xml");
|
||||
settingsPath = Utils::FileSystem::getAppDataDirectory() + "/es_settings.xml";
|
||||
else
|
||||
settingsPath = Utils::FileSystem::getAppDataDirectory()
|
||||
.append("settings")
|
||||
.append("es_settings.xml");
|
||||
settingsPath = Utils::FileSystem::getAppDataDirectory() + "/settings/es_settings.xml";
|
||||
|
||||
if (!Utils::FileSystem::existsSTD(settingsPath)) {
|
||||
if (!Utils::FileSystem::exists(settingsPath)) {
|
||||
LOG(LogInfo) << "Settings file es_settings.xml does not exist, creating it...";
|
||||
Settings::getInstance()->saveFile();
|
||||
}
|
||||
|
@ -743,12 +734,11 @@ int main(int argc, char* argv[])
|
|||
|
||||
{
|
||||
// Create the gamelists folder in the application data directory.
|
||||
const std::filesystem::path gamelistsDir {
|
||||
Utils::FileSystem::getAppDataDirectory().append("gamelists")};
|
||||
if (!Utils::FileSystem::existsSTD(gamelistsDir)) {
|
||||
LOG(LogInfo) << "Creating gamelists directory \"" << gamelistsDir.string() << "\"...";
|
||||
Utils::FileSystem::createDirectory(gamelistsDir.string());
|
||||
if (!Utils::FileSystem::existsSTD(gamelistsDir)) {
|
||||
const std::string gamelistsDir {Utils::FileSystem::getAppDataDirectory() + "/gamelists"};
|
||||
if (!Utils::FileSystem::exists(gamelistsDir)) {
|
||||
LOG(LogInfo) << "Creating gamelists directory \"" << gamelistsDir << "\"...";
|
||||
Utils::FileSystem::createDirectory(gamelistsDir);
|
||||
if (!Utils::FileSystem::exists(gamelistsDir)) {
|
||||
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
||||
}
|
||||
}
|
||||
|
@ -756,36 +746,34 @@ int main(int argc, char* argv[])
|
|||
|
||||
{
|
||||
#if defined(__ANDROID__)
|
||||
const std::filesystem::path themeDir {
|
||||
Utils::FileSystem::getAppDataDirectory().append("themes")};
|
||||
if (!Utils::FileSystem::existsSTD(themeDir)) {
|
||||
LOG(LogInfo) << "Creating themes directory \"" << themeDir.string() << "\"...";
|
||||
const std::string themeDir {Utils::FileSystem::getAppDataDirectory() + "/themes"};
|
||||
if (!Utils::FileSystem::exists(themeDir)) {
|
||||
LOG(LogInfo) << "Creating themes directory \"" << themeDir << "\"...";
|
||||
|
||||
Utils::FileSystem::createDirectory(themeDir.string());
|
||||
if (!Utils::FileSystem::existsSTD(themeDir)) {
|
||||
Utils::FileSystem::createDirectory(themeDir);
|
||||
if (!Utils::FileSystem::exists(themeDir)) {
|
||||
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Create the themes folder in the application data directory (or elsewhere if the
|
||||
// UserThemeDirectory setting has been defined).
|
||||
const std::filesystem::path defaultUserThemeDir {
|
||||
Utils::FileSystem::getAppDataDirectory().append("themes")};
|
||||
std::filesystem::path userThemeDirSetting {Utils::FileSystem::expandHomePath(
|
||||
const std::string defaultUserThemeDir {Utils::FileSystem::getAppDataDirectory() +
|
||||
"/themes"};
|
||||
std::string userThemeDirSetting {Utils::FileSystem::expandHomePath(
|
||||
Settings::getInstance()->getString("UserThemeDirectory"))};
|
||||
std::filesystem::path userThemeDirectory;
|
||||
std::string userThemeDirectory;
|
||||
|
||||
if (userThemeDirSetting.empty())
|
||||
userThemeDirectory = defaultUserThemeDir;
|
||||
else
|
||||
userThemeDirectory = userThemeDirSetting;
|
||||
|
||||
if (!Utils::FileSystem::existsSTD(userThemeDirectory)) {
|
||||
LOG(LogInfo) << "Creating themes directory \"" << userThemeDirectory.string()
|
||||
<< "\"...";
|
||||
if (!Utils::FileSystem::exists(userThemeDirectory)) {
|
||||
LOG(LogInfo) << "Creating themes directory \"" << userThemeDirectory << "\"...";
|
||||
|
||||
Utils::FileSystem::createDirectory(userThemeDirectory.string());
|
||||
if (!Utils::FileSystem::existsSTD(userThemeDirectory)) {
|
||||
Utils::FileSystem::createDirectory(userThemeDirectory);
|
||||
if (!Utils::FileSystem::exists(userThemeDirectory)) {
|
||||
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
||||
}
|
||||
}
|
||||
|
@ -795,12 +783,11 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
// Create the scripts folder in the application data directory. This is only required
|
||||
// for custom event scripts so it's also created as a convenience.
|
||||
const std::filesystem::path scriptsDir {
|
||||
Utils::FileSystem::getAppDataDirectory().append("scripts")};
|
||||
if (!Utils::FileSystem::existsSTD(scriptsDir)) {
|
||||
LOG(LogInfo) << "Creating scripts directory \"" << scriptsDir.string() << "\"...";
|
||||
Utils::FileSystem::createDirectory(scriptsDir.string());
|
||||
if (!Utils::FileSystem::existsSTD(scriptsDir)) {
|
||||
const std::string scriptsDir {Utils::FileSystem::getAppDataDirectory() + "/scripts"};
|
||||
if (!Utils::FileSystem::exists(scriptsDir)) {
|
||||
LOG(LogInfo) << "Creating scripts directory \"" << scriptsDir << "\"...";
|
||||
Utils::FileSystem::createDirectory(scriptsDir);
|
||||
if (!Utils::FileSystem::exists(scriptsDir)) {
|
||||
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
||||
}
|
||||
}
|
||||
|
@ -808,24 +795,21 @@ int main(int argc, char* argv[])
|
|||
|
||||
{
|
||||
// Create the screensavers and screensavers/custom_slideshow directories.
|
||||
const std::filesystem::path screensaversDir {
|
||||
Utils::FileSystem::getAppDataDirectory().append("screensavers")};
|
||||
const std::filesystem::path slideshowDir {Utils::FileSystem::getAppDataDirectory()
|
||||
.append("screensavers")
|
||||
.append("custom_slideshow")};
|
||||
if (!Utils::FileSystem::existsSTD(screensaversDir)) {
|
||||
LOG(LogInfo) << "Creating screensavers directory \"" << screensaversDir.string()
|
||||
<< "\"...";
|
||||
Utils::FileSystem::createDirectory(screensaversDir.string());
|
||||
if (!Utils::FileSystem::existsSTD(screensaversDir)) {
|
||||
const std::string screensaversDir {Utils::FileSystem::getAppDataDirectory() +
|
||||
"/screensavers"};
|
||||
const std::string slideshowDir {Utils::FileSystem::getAppDataDirectory() +
|
||||
"/screensavers/custom_slideshow"};
|
||||
if (!Utils::FileSystem::exists(screensaversDir)) {
|
||||
LOG(LogInfo) << "Creating screensavers directory \"" << screensaversDir << "\"...";
|
||||
Utils::FileSystem::createDirectory(screensaversDir);
|
||||
if (!Utils::FileSystem::exists(screensaversDir)) {
|
||||
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
||||
}
|
||||
}
|
||||
if (!Utils::FileSystem::existsSTD(slideshowDir)) {
|
||||
LOG(LogInfo) << "Creating custom_slideshow directory \"" << slideshowDir.string()
|
||||
<< "\"...";
|
||||
Utils::FileSystem::createDirectory(slideshowDir.string());
|
||||
if (!Utils::FileSystem::existsSTD(slideshowDir)) {
|
||||
if (!Utils::FileSystem::exists(slideshowDir)) {
|
||||
LOG(LogInfo) << "Creating custom_slideshow directory \"" << slideshowDir << "\"...";
|
||||
Utils::FileSystem::createDirectory(slideshowDir);
|
||||
if (!Utils::FileSystem::exists(slideshowDir)) {
|
||||
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
||||
}
|
||||
}
|
||||
|
@ -834,25 +818,22 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
if (!Settings::getInstance()->getBool("LegacyAppDataDirectory")) {
|
||||
// Create the controllers folder in the application data directory.
|
||||
const std::filesystem::path controllersDir {
|
||||
Utils::FileSystem::getAppDataDirectory().append("controllers")};
|
||||
if (!Utils::FileSystem::existsSTD(controllersDir)) {
|
||||
LOG(LogInfo) << "Creating controllers directory \"" << controllersDir.string()
|
||||
<< "\"...";
|
||||
Utils::FileSystem::createDirectory(controllersDir.string());
|
||||
if (!Utils::FileSystem::existsSTD(controllersDir)) {
|
||||
const std::string controllersDir {Utils::FileSystem::getAppDataDirectory() +
|
||||
"/controllers"};
|
||||
if (!Utils::FileSystem::exists(controllersDir)) {
|
||||
LOG(LogInfo) << "Creating controllers directory \"" << controllersDir << "\"...";
|
||||
Utils::FileSystem::createDirectory(controllersDir);
|
||||
if (!Utils::FileSystem::exists(controllersDir)) {
|
||||
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
||||
}
|
||||
}
|
||||
std::filesystem::path configPathOld {
|
||||
Utils::FileSystem::getAppDataDirectory().append("es_controller_mappings.cfg")};
|
||||
std::filesystem::path configPathNew {Utils::FileSystem::getAppDataDirectory()
|
||||
.append("controllers")
|
||||
.append("es_controller_mappings.cfg")};
|
||||
if (!Utils::FileSystem::existsSTD(configPathNew) &&
|
||||
Utils::FileSystem::existsSTD(configPathOld)) {
|
||||
Utils::FileSystem::renameFile(configPathOld.string(), configPathNew.string(),
|
||||
false);
|
||||
std::string configPathOld {Utils::FileSystem::getAppDataDirectory() +
|
||||
"/es_controller_mappings.cfg"};
|
||||
std::string configPathNew {Utils::FileSystem::getAppDataDirectory() +
|
||||
"/controllers/es_controller_mappings.cfg"};
|
||||
if (!Utils::FileSystem::exists(configPathNew) &&
|
||||
Utils::FileSystem::exists(configPathOld)) {
|
||||
Utils::FileSystem::renameFile(configPathOld, configPathNew, false);
|
||||
migratedSettings = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace
|
|||
|
||||
std::string getScrapersResouceDir()
|
||||
{
|
||||
return Utils::FileSystem::getAppDataDirectory().append(SCRAPER_RESOURCES_DIR).string();
|
||||
return Utils::FileSystem::getAppDataDirectory() + "/" + SCRAPER_RESOURCES_DIR;
|
||||
}
|
||||
|
||||
std::string TheGamesDBJSONRequestResources::getApiKey() const { return GamesDBAPIKey; }
|
||||
|
|
|
@ -1476,7 +1476,7 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary)
|
|||
glm::ivec2 {static_cast<int>(mSize.x), static_cast<int>(mSize.y)});
|
||||
};
|
||||
|
||||
auto renderChildCondFunc = [this, &viewState](GuiComponent* child, glm::mat4 trans) {
|
||||
auto renderChildCondFunc = [&viewState](GuiComponent* child, glm::mat4 trans) {
|
||||
bool renderChild {false};
|
||||
if (!ViewController::getInstance()->isCameraMoving())
|
||||
renderChild = true;
|
||||
|
|
|
@ -142,8 +142,8 @@ void ViewController::legacyAppDataDialog()
|
|||
const std::string upgradeMessage {
|
||||
"AS OF ES-DE 3.0.0 THE APPLICATION DATA DIRECTORY HAS CHANGED FROM \".emulationstation\" "
|
||||
"to \"ES-DE\"\nPLEASE RENAME YOUR CURRENT DATA DIRECTORY:\n" +
|
||||
Utils::FileSystem::getAppDataDirectory().string() + "\nTO THE FOLLOWING:\n" +
|
||||
Utils::FileSystem::getAppDataDirectory().parent_path().append("ES-DE").string()};
|
||||
Utils::FileSystem::getAppDataDirectory() + "\nTO THE FOLLOWING:\n" +
|
||||
Utils::FileSystem::getParent(Utils::FileSystem::getAppDataDirectory()) + "/ES-DE"};
|
||||
|
||||
mWindow->pushGui(new GuiMsgBox(
|
||||
HelpStyle(), upgradeMessage.c_str(), "OK", [] {}, "", nullptr, "", nullptr, nullptr, true,
|
||||
|
|
|
@ -86,23 +86,21 @@ void InputManager::init()
|
|||
// the bundled mapping is incorrect, or the SDL version is a bit older, it makes sense to be
|
||||
// able to customize this. If a controller GUID is present in the mappings file that is
|
||||
// already present inside SDL, the custom mapping will overwrite the bundled one.
|
||||
std::filesystem::path mappingsFile;
|
||||
std::string mappingsFile;
|
||||
|
||||
if (Settings::getInstance()->getBool("LegacyAppDataDirectory")) {
|
||||
mappingsFile =
|
||||
Utils::FileSystem::getAppDataDirectory().append("es_controller_mappings.cfg");
|
||||
mappingsFile = Utils::FileSystem::getAppDataDirectory() + "/es_controller_mappings.cfg";
|
||||
}
|
||||
else {
|
||||
mappingsFile = Utils::FileSystem::getAppDataDirectory()
|
||||
.append("controllers")
|
||||
.append("es_controller_mappings.cfg");
|
||||
mappingsFile =
|
||||
Utils::FileSystem::getAppDataDirectory() + "/controllers/es_controller_mappings.cfg";
|
||||
}
|
||||
|
||||
if (!Utils::FileSystem::existsSTD(mappingsFile))
|
||||
if (!Utils::FileSystem::exists(mappingsFile))
|
||||
mappingsFile = ResourceManager::getInstance().getResourcePath(
|
||||
":/controllers/es_controller_mappings.cfg");
|
||||
|
||||
int controllerMappings {SDL_GameControllerAddMappingsFromFile(mappingsFile.string().c_str())};
|
||||
int controllerMappings {SDL_GameControllerAddMappingsFromFile(mappingsFile.c_str())};
|
||||
|
||||
if (controllerMappings != -1 && controllerMappings != 0) {
|
||||
LOG(LogInfo) << "Loaded " << controllerMappings << " controller "
|
||||
|
@ -264,28 +262,18 @@ void InputManager::doOnFinish()
|
|||
|
||||
std::string InputManager::getConfigPath()
|
||||
{
|
||||
if (Settings::getInstance()->getBool("LegacyAppDataDirectory")) {
|
||||
return Utils::FileSystem::getAppDataDirectory().append("es_input.xml").string();
|
||||
}
|
||||
else {
|
||||
return Utils::FileSystem::getAppDataDirectory()
|
||||
.append("settings")
|
||||
.append("es_input.xml")
|
||||
.string();
|
||||
}
|
||||
if (Settings::getInstance()->getBool("LegacyAppDataDirectory"))
|
||||
return Utils::FileSystem::getAppDataDirectory() + "/es_input.xml";
|
||||
else
|
||||
return Utils::FileSystem::getAppDataDirectory() + "/settings/es_input.xml";
|
||||
}
|
||||
|
||||
std::string InputManager::getTemporaryConfigPath()
|
||||
{
|
||||
if (Settings::getInstance()->getBool("LegacyAppDataDirectory")) {
|
||||
return Utils::FileSystem::getAppDataDirectory().append("es_temporaryinput.xml").string();
|
||||
}
|
||||
else {
|
||||
return Utils::FileSystem::getAppDataDirectory()
|
||||
.append("settings")
|
||||
.append("es_temporaryinput.xml")
|
||||
.string();
|
||||
}
|
||||
if (Settings::getInstance()->getBool("LegacyAppDataDirectory"))
|
||||
return Utils::FileSystem::getAppDataDirectory() + "/es_temporaryinput.xml";
|
||||
else
|
||||
return Utils::FileSystem::getAppDataDirectory() + "/settings/es_temporaryinput.xml";
|
||||
}
|
||||
|
||||
int InputManager::getNumConfiguredDevices()
|
||||
|
|
|
@ -26,13 +26,13 @@ void Log::setReportingLevel(LogLevel level)
|
|||
void Log::init()
|
||||
{
|
||||
if (Settings::getInstance()->getBool("LegacyAppDataDirectory"))
|
||||
sLogPath = Utils::FileSystem::getAppDataDirectory().append("es_log.txt");
|
||||
sLogPath = Utils::FileSystem::getAppDataDirectory() + "/es_log.txt";
|
||||
else
|
||||
sLogPath = Utils::FileSystem::getAppDataDirectory().append("logs").append("es_log.txt");
|
||||
sLogPath = Utils::FileSystem::getAppDataDirectory() + "/logs/es_log.txt";
|
||||
|
||||
Utils::FileSystem::removeFile(sLogPath.string() + ".bak");
|
||||
Utils::FileSystem::removeFile(sLogPath + ".bak");
|
||||
// Rename the previous log file.
|
||||
Utils::FileSystem::renameFile(sLogPath.string(), sLogPath.string() + ".bak", true);
|
||||
Utils::FileSystem::renameFile(sLogPath, sLogPath + ".bak", true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,9 @@ void Log::open()
|
|||
{
|
||||
std::unique_lock<std::mutex> lock {sLogMutex};
|
||||
#if defined(_WIN64)
|
||||
sFile.open(Utils::String::stringToWideString(sLogPath.string()).c_str());
|
||||
sFile.open(Utils::String::stringToWideString(sLogPath).c_str());
|
||||
#else
|
||||
sFile.open(sLogPath.string().c_str());
|
||||
sFile.open(sLogPath.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ private:
|
|||
static inline std::ofstream sFile;
|
||||
static inline LogLevel sReportingLevel = LogInfo;
|
||||
static inline std::mutex sLogMutex;
|
||||
static inline std::filesystem::path sLogPath;
|
||||
static inline std::string sLogPath;
|
||||
LogLevel mMessageLevel;
|
||||
};
|
||||
|
||||
|
|
|
@ -37,12 +37,12 @@ namespace Scripting
|
|||
<< "\" \"" << arg3 << "\" \"" << arg4 << "\"";
|
||||
|
||||
std::list<std::string> scriptDirList;
|
||||
std::filesystem::path scriptDir;
|
||||
std::string scriptDir;
|
||||
|
||||
// Check in application data directory.
|
||||
scriptDir = Utils::FileSystem::getAppDataDirectory().append("scripts").append(eventName);
|
||||
if (Utils::FileSystem::existsSTD(scriptDir))
|
||||
scriptDirList.push_back(scriptDir.string());
|
||||
scriptDir = Utils::FileSystem::getAppDataDirectory() + "/scripts/" + eventName;
|
||||
if (Utils::FileSystem::exists(scriptDir))
|
||||
scriptDirList.push_back(scriptDir);
|
||||
|
||||
for (auto dirIt = scriptDirList.cbegin(); dirIt != scriptDirList.cend(); ++dirIt) {
|
||||
std::list<std::string> scripts {Utils::FileSystem::getDirContent(*dirIt)};
|
||||
|
|
|
@ -78,7 +78,8 @@ Settings::Settings()
|
|||
{
|
||||
mWasChanged = false;
|
||||
setDefaults();
|
||||
if (Utils::FileSystem::getAppDataDirectory().filename().string() == ".emulationstation")
|
||||
if (Utils::FileSystem::getFileName(Utils::FileSystem::getAppDataDirectory()) ==
|
||||
".emulationstation")
|
||||
mBoolMap["LegacyAppDataDirectory"] = std::make_pair(true, true);
|
||||
loadFile();
|
||||
}
|
||||
|
@ -367,13 +368,12 @@ void Settings::setDefaults()
|
|||
|
||||
void Settings::saveFile()
|
||||
{
|
||||
std::filesystem::path path;
|
||||
std::string path;
|
||||
if (mBoolMap["LegacyAppDataDirectory"].second == true) {
|
||||
path = Utils::FileSystem::getAppDataDirectory().append("es_settings.xml");
|
||||
path = Utils::FileSystem::getAppDataDirectory() + "/es_settings.xml";
|
||||
}
|
||||
else {
|
||||
path =
|
||||
Utils::FileSystem::getAppDataDirectory().append("settings").append("es_settings.xml");
|
||||
path = Utils::FileSystem::getAppDataDirectory() + "/settings/es_settings.xml";
|
||||
}
|
||||
|
||||
pugi::xml_document doc;
|
||||
|
@ -393,9 +393,9 @@ void Settings::saveFile()
|
|||
}
|
||||
|
||||
#if defined(_WIN64)
|
||||
doc.save_file(Utils::String::stringToWideString(path.string()).c_str());
|
||||
doc.save_file(Utils::String::stringToWideString(path).c_str());
|
||||
#else
|
||||
doc.save_file(path.string().c_str());
|
||||
doc.save_file(path.c_str());
|
||||
#endif
|
||||
|
||||
Scripting::fireEvent("config-changed");
|
||||
|
@ -404,24 +404,20 @@ void Settings::saveFile()
|
|||
|
||||
void Settings::loadFile()
|
||||
{
|
||||
std::filesystem::path path;
|
||||
if (mBoolMap["LegacyAppDataDirectory"].second == true) {
|
||||
path = Utils::FileSystem::getAppDataDirectory().append("es_settings.xml");
|
||||
}
|
||||
else {
|
||||
path =
|
||||
Utils::FileSystem::getAppDataDirectory().append("settings").append("es_settings.xml");
|
||||
}
|
||||
std::string path;
|
||||
if (mBoolMap["LegacyAppDataDirectory"].second == true)
|
||||
path = Utils::FileSystem::getAppDataDirectory() + "/es_settings.xml";
|
||||
else
|
||||
path = Utils::FileSystem::getAppDataDirectory() + "/settings/es_settings.xml";
|
||||
|
||||
if (!Utils::FileSystem::existsSTD(path))
|
||||
if (!Utils::FileSystem::exists(path))
|
||||
return;
|
||||
|
||||
pugi::xml_document doc;
|
||||
#if defined(_WIN64)
|
||||
pugi::xml_parse_result result {
|
||||
doc.load_file(Utils::String::stringToWideString(path.string()).c_str())};
|
||||
pugi::xml_parse_result result {doc.load_file(Utils::String::stringToWideString(path).c_str())};
|
||||
#else
|
||||
pugi::xml_parse_result result {doc.load_file(path.string().c_str())};
|
||||
pugi::xml_parse_result result {doc.load_file(path.c_str())};
|
||||
#endif
|
||||
if (!result) {
|
||||
LOG(LogError) << "Couldn't parse the es_settings.xml file: " << result.description();
|
||||
|
|
|
@ -671,66 +671,74 @@ void ThemeData::populateThemes()
|
|||
// by default), then under the data installation directory (Unix only) and last under the ES-DE
|
||||
// binary directory.
|
||||
#if defined(__ANDROID__)
|
||||
const std::filesystem::path userThemeDirectory {
|
||||
Utils::FileSystem::getInternalAppDataDirectory().append("themes")};
|
||||
const std::string userThemeDirectory {Utils::FileSystem::getInternalAppDataDirectory() +
|
||||
"/themes"};
|
||||
#else
|
||||
const std::filesystem::path defaultUserThemeDir {
|
||||
Utils::FileSystem::getAppDataDirectory().append("themes")};
|
||||
const std::filesystem::path userThemeDirSetting {Utils::FileSystem::expandHomePath(
|
||||
const std::string defaultUserThemeDir {Utils::FileSystem::getAppDataDirectory() + "/themes"};
|
||||
const std::string userThemeDirSetting {Utils::FileSystem::expandHomePath(
|
||||
Settings::getInstance()->getString("UserThemeDirectory"))};
|
||||
std::filesystem::path userThemeDirectory;
|
||||
std::string userThemeDirectory;
|
||||
|
||||
if (userThemeDirSetting.empty()) {
|
||||
userThemeDirectory = defaultUserThemeDir;
|
||||
}
|
||||
else if (Utils::FileSystem::isDirectorySTD(userThemeDirSetting) ||
|
||||
Utils::FileSystem::isSymlinkSTD(userThemeDirSetting)) {
|
||||
else if (Utils::FileSystem::isDirectory(userThemeDirSetting) ||
|
||||
Utils::FileSystem::isSymlink(userThemeDirSetting)) {
|
||||
userThemeDirectory = userThemeDirSetting;
|
||||
LOG(LogInfo) << "Setting user theme directory to \"" << userThemeDirectory.string() << "\"";
|
||||
#if defined(_WIN64)
|
||||
LOG(LogInfo) << "Setting user theme directory to \""
|
||||
<< Utils::String::replace(userThemeDirectory, "/", "\\") << "\"";
|
||||
#else
|
||||
LOG(LogInfo) << "Setting user theme directory to \"" << userThemeDirectory << "\"";
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
LOG(LogWarning) << "Requested user theme directory \"" << userThemeDirSetting.string()
|
||||
LOG(LogWarning) << "Requested user theme directory \"" << userThemeDirSetting
|
||||
<< "\" does not exist or is not a directory, reverting to \""
|
||||
<< defaultUserThemeDir.string() << "\"";
|
||||
<< defaultUserThemeDir << "\"";
|
||||
userThemeDirectory = defaultUserThemeDir;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
const std::vector<std::filesystem::path> themePaths {
|
||||
Utils::FileSystem::getProgramDataPath().append("themes"), userThemeDirectory,
|
||||
Utils::FileSystem::getAppDataDirectory().append("themes")};
|
||||
const std::vector<std::string> themePaths {
|
||||
Utils::FileSystem::getProgramDataPath() + "/themes", userThemeDirectory,
|
||||
Utils::FileSystem::getAppDataDirectory() + "/themes"};
|
||||
#elif defined(__APPLE__)
|
||||
const std::vector<std::filesystem::path> themePaths {
|
||||
Utils::FileSystem::getExePathSTD().append("themes"),
|
||||
Utils::FileSystem::getExePathSTD().parent_path().append("Resources").append("themes"),
|
||||
userThemeDirectory};
|
||||
const std::vector<std::string> themePaths {
|
||||
Utils::FileSystem::getExePath() + "/themes",
|
||||
Utils::FileSystem::getExePath() + "/../Resources/themes", userThemeDirectory};
|
||||
#elif defined(_WIN64) || defined(APPIMAGE_BUILD)
|
||||
const std::vector<std::filesystem::path> themePaths {
|
||||
Utils::FileSystem::getExePathSTD().append("themes"), userThemeDirectory};
|
||||
const std::vector<std::string> themePaths {Utils::FileSystem::getExePath() + "/themes",
|
||||
userThemeDirectory};
|
||||
#else
|
||||
const std::vector<std::filesystem::path> themePaths {
|
||||
Utils::FileSystem::getExePathSTD().append("themes"),
|
||||
Utils::FileSystem::getProgramDataPath().append("themes"), userThemeDirectory};
|
||||
const std::vector<std::string> themePaths {Utils::FileSystem::getExePath() + "/themes",
|
||||
Utils::FileSystem::getProgramDataPath() + "/themes",
|
||||
userThemeDirectory};
|
||||
#endif
|
||||
|
||||
for (auto path : themePaths) {
|
||||
if (!Utils::FileSystem::isDirectorySTD(path))
|
||||
if (!Utils::FileSystem::isDirectory(path))
|
||||
continue;
|
||||
|
||||
Utils::FileSystem::FileList dirContent {Utils::FileSystem::getDirContentSTD(path)};
|
||||
Utils::FileSystem::StringList dirContent {Utils::FileSystem::getDirContent(path)};
|
||||
|
||||
for (Utils::FileSystem::FileList::const_iterator it = dirContent.cbegin();
|
||||
for (Utils::FileSystem::StringList::const_iterator it = dirContent.cbegin();
|
||||
it != dirContent.cend(); ++it) {
|
||||
if (Utils::FileSystem::isDirectorySTD(*it)) {
|
||||
const std::string themeDirName {Utils::FileSystem::getFileNameSTD(*it).string()};
|
||||
if (Utils::FileSystem::isDirectory(*it)) {
|
||||
const std::string themeDirName {Utils::FileSystem::getFileName(*it)};
|
||||
if (themeDirName == "themes-list" ||
|
||||
(themeDirName.length() >= 8 &&
|
||||
Utils::String::toLower(themeDirName.substr(themeDirName.length() - 8, 8)) ==
|
||||
"disabled"))
|
||||
continue;
|
||||
LOG(LogDebug) << "Loading theme capabilities for \"" << (*it).string() << "\"...";
|
||||
ThemeCapability capabilities {parseThemeCapabilities((*it).string())};
|
||||
#if defined(_WIN64)
|
||||
LOG(LogDebug) << "Loading theme capabilities for \""
|
||||
<< Utils::String::replace(*it, "/", "\\") << "\"...";
|
||||
#else
|
||||
LOG(LogDebug) << "Loading theme capabilities for \"" << *it << "\"...";
|
||||
#endif
|
||||
ThemeCapability capabilities {parseThemeCapabilities((*it))};
|
||||
|
||||
if (!capabilities.validTheme)
|
||||
continue;
|
||||
|
@ -739,8 +747,12 @@ void ThemeData::populateThemes()
|
|||
if (capabilities.themeName != "")
|
||||
themeName.append(" (\"").append(capabilities.themeName).append("\")");
|
||||
|
||||
LOG(LogInfo) << "Added theme \"" << (*it).string() << "\"" << themeName;
|
||||
|
||||
#if defined(_WIN64)
|
||||
LOG(LogInfo) << "Added theme \"" << Utils::String::replace(*it, "/", "\\") << "\""
|
||||
<< themeName;
|
||||
#else
|
||||
LOG(LogInfo) << "Added theme \"" << *it << "\"" << themeName;
|
||||
#endif
|
||||
int aspectRatios {0};
|
||||
if (capabilities.aspectRatios.size() > 0)
|
||||
aspectRatios = static_cast<int>(capabilities.aspectRatios.size()) - 1;
|
||||
|
@ -752,7 +764,7 @@ void ThemeData::populateThemes()
|
|||
<< " and " << capabilities.transitions.size() << " transition"
|
||||
<< (capabilities.transitions.size() != 1 ? "s" : "");
|
||||
|
||||
Theme theme {(*it).string(), capabilities};
|
||||
Theme theme {*it, capabilities};
|
||||
sThemes[theme.getName()] = theme;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,7 @@ std::string ResourceManager::getResourcePath(const std::string& path, bool termi
|
|||
if ((path[0] == ':') && (path[1] == '/')) {
|
||||
|
||||
// Check under the home directory.
|
||||
std::string testHome {
|
||||
Utils::FileSystem::getAppDataDirectory().append("resources").string() + "/" + &path[2]};
|
||||
std::string testHome {Utils::FileSystem::getAppDataDirectory() + "/resources/" + &path[2]};
|
||||
if (Utils::FileSystem::exists(testHome))
|
||||
return testHome;
|
||||
|
||||
|
@ -43,7 +42,7 @@ std::string ResourceManager::getResourcePath(const std::string& path, bool termi
|
|||
}
|
||||
#elif (defined(__unix__) && !defined(APPIMAGE_BUILD)) || defined(__ANDROID__)
|
||||
// Check in the program data directory.
|
||||
std::string testDataPath {Utils::FileSystem::getProgramDataPath().string() + "/resources/" +
|
||||
std::string testDataPath {Utils::FileSystem::getProgramDataPath() + "/resources/" +
|
||||
&path[2]};
|
||||
if (Utils::FileSystem::exists(testDataPath))
|
||||
return testDataPath;
|
||||
|
|
|
@ -42,14 +42,14 @@
|
|||
// build environment is broken.
|
||||
#if defined(__unix__)
|
||||
#if defined(ES_INSTALL_PREFIX)
|
||||
const std::filesystem::path installPrefix {ES_INSTALL_PREFIX};
|
||||
const std::string installPrefix {ES_INSTALL_PREFIX};
|
||||
#else
|
||||
#if defined(__linux__)
|
||||
const std::filesystem::path installPrefix {"/usr"};
|
||||
const std::string installPrefix {"/usr"};
|
||||
#elif defined(__NetBSD__)
|
||||
const std::filesystem::path installPrefix {"/usr/pkg"};
|
||||
const std::string installPrefix {"/usr/pkg"};
|
||||
#else
|
||||
const std::filesystem::path installPrefix {"/usr/local"};
|
||||
const std::string installPrefix {"/usr/local"};
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
@ -59,9 +59,8 @@ namespace Utils
|
|||
namespace FileSystem
|
||||
{
|
||||
static std::string homePath;
|
||||
static std::filesystem::path homePathSTD;
|
||||
static std::filesystem::path exePath;
|
||||
static std::filesystem::path esBinary;
|
||||
static std::string exePath;
|
||||
static std::string esBinary;
|
||||
|
||||
StringList getDirContent(const std::string& path, const bool recursive)
|
||||
{
|
||||
|
@ -100,26 +99,6 @@ namespace Utils
|
|||
return contentList;
|
||||
}
|
||||
|
||||
FileList getDirContentSTD(const std::filesystem::path& path, const bool recursive)
|
||||
{
|
||||
FileList fileList;
|
||||
|
||||
if (!isDirectorySTD(path))
|
||||
return fileList;
|
||||
|
||||
if (recursive) {
|
||||
for (auto& entry : std::filesystem::recursive_directory_iterator(path))
|
||||
fileList.emplace_back(entry);
|
||||
}
|
||||
else {
|
||||
for (auto& entry : std::filesystem::directory_iterator(path))
|
||||
fileList.emplace_back(entry);
|
||||
}
|
||||
|
||||
fileList.sort();
|
||||
return fileList;
|
||||
}
|
||||
|
||||
StringList getMatchingFiles(const std::string& pattern)
|
||||
{
|
||||
StringList files;
|
||||
|
@ -189,7 +168,6 @@ namespace Utils
|
|||
{
|
||||
// Set home path.
|
||||
homePath = getGenericPath(path);
|
||||
homePathSTD = std::filesystem::path {homePath};
|
||||
}
|
||||
|
||||
std::string getHomePath()
|
||||
|
@ -235,56 +213,11 @@ namespace Utils
|
|||
|
||||
// No homepath found, fall back to current working directory.
|
||||
if (!homePath.length())
|
||||
homePath = std::filesystem::current_path().string();
|
||||
homePath = getCWDPath();
|
||||
|
||||
return homePath;
|
||||
}
|
||||
|
||||
std::filesystem::path getHomePathSTD()
|
||||
{
|
||||
// Only construct the homepath once.
|
||||
if (!homePathSTD.empty())
|
||||
return homePathSTD;
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
homePathSTD =
|
||||
std::filesystem::path {getGenericPath(FileSystemVariables::sAppDataDirectory)};
|
||||
return homePathSTD;
|
||||
#endif
|
||||
#if defined(_WIN64)
|
||||
// On Windows we need to check HOMEDRIVE and HOMEPATH.
|
||||
std::wstring envHomeDrive;
|
||||
std::wstring envHomePath;
|
||||
#if defined(_MSC_VER) // MSVC compiler.
|
||||
wchar_t* buffer;
|
||||
if (!_wdupenv_s(&buffer, nullptr, L"HOMEDRIVE"))
|
||||
envHomeDrive = buffer;
|
||||
if (!_wdupenv_s(&buffer, nullptr, L"HOMEPATH"))
|
||||
envHomePath = buffer;
|
||||
#else
|
||||
envHomeDrive = _wgetenv(L"HOMEDRIVE");
|
||||
envHomePath = _wgetenv(L"HOMEPATH");
|
||||
#endif
|
||||
if (envHomeDrive.length() && envHomePath.length()) {
|
||||
homePathSTD = envHomeDrive;
|
||||
homePathSTD.append(envHomePath);
|
||||
}
|
||||
|
||||
#else
|
||||
std::string envHome;
|
||||
if (getenv("HOME") != nullptr)
|
||||
envHome = getenv("HOME");
|
||||
if (envHome.length())
|
||||
homePathSTD = std::filesystem::path {getGenericPath(envHome)};
|
||||
#endif
|
||||
|
||||
// No homepath found, fall back to current working directory.
|
||||
if (homePathSTD.empty())
|
||||
homePathSTD = std::filesystem::current_path();
|
||||
|
||||
return homePathSTD;
|
||||
}
|
||||
|
||||
std::string getSystemHomeDirectory()
|
||||
{
|
||||
#if defined(_WIN64)
|
||||
|
@ -313,22 +246,20 @@ namespace Utils
|
|||
return "";
|
||||
}
|
||||
|
||||
std::filesystem::path getAppDataDirectory()
|
||||
std::string getAppDataDirectory()
|
||||
{
|
||||
#if defined(__ANDROID__)
|
||||
return getHomePathSTD();
|
||||
return getHomePath();
|
||||
#else
|
||||
if (FileSystemVariables::sAppDataDirectory.empty()) {
|
||||
if (Utils::FileSystem::existsSTD(getHomePathSTD().append("ES-DE"))) {
|
||||
FileSystemVariables::sAppDataDirectory = getHomePathSTD().append("ES-DE");
|
||||
if (Utils::FileSystem::exists(getHomePath() + "/ES-DE")) {
|
||||
FileSystemVariables::sAppDataDirectory = getHomePath() + "/ES-DE";
|
||||
}
|
||||
else if (Utils::FileSystem::existsSTD(
|
||||
getHomePathSTD().append(".emulationstation"))) {
|
||||
FileSystemVariables::sAppDataDirectory =
|
||||
getHomePathSTD().append(".emulationstation");
|
||||
else if (Utils::FileSystem::exists(getHomePath() + "/.emulationstation")) {
|
||||
FileSystemVariables::sAppDataDirectory = getHomePath() + "/.emulationstation";
|
||||
}
|
||||
else {
|
||||
FileSystemVariables::sAppDataDirectory = getHomePathSTD().append("ES-DE");
|
||||
FileSystemVariables::sAppDataDirectory = getHomePath() + "/ES-DE";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,12 +267,27 @@ namespace Utils
|
|||
#endif
|
||||
}
|
||||
|
||||
std::filesystem::path getInternalAppDataDirectory()
|
||||
std::string getInternalAppDataDirectory()
|
||||
{
|
||||
#if defined(__ANDROID__)
|
||||
return AndroidVariables::sExternalDataDirectory;
|
||||
#else
|
||||
return std::filesystem::path {};
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string getCWDPath()
|
||||
{
|
||||
// Return current working directory.
|
||||
|
||||
#if defined(_WIN64)
|
||||
wchar_t tempWide[512];
|
||||
return (_wgetcwd(tempWide, 512) ?
|
||||
getGenericPath(Utils::String::wideStringToString(tempWide)) :
|
||||
"");
|
||||
#else
|
||||
char temp[512];
|
||||
return (getcwd(temp, 512) ? getGenericPath(temp) : "");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -364,8 +310,8 @@ namespace Utils
|
|||
|
||||
// Using a temporary file is the only viable solution I've found to communicate
|
||||
// between the sandbox and the outside world.
|
||||
const std::string tempFile {Utils::FileSystem::getAppDataDirectory().string() +
|
||||
".flatpak_emulator_binary_path.tmp"};
|
||||
const std::string& tempFile {Utils::FileSystem::getAppDataDirectory() +
|
||||
"/.flatpak_emulator_binary_path.tmp"};
|
||||
|
||||
std::string emulatorPath;
|
||||
|
||||
|
@ -410,73 +356,56 @@ namespace Utils
|
|||
|
||||
void setExePath(const std::string& path)
|
||||
{
|
||||
std::string exePathTemp;
|
||||
|
||||
constexpr int pathMax {32767};
|
||||
#if defined(_WIN64)
|
||||
std::wstring result(pathMax, 0);
|
||||
if (GetModuleFileNameW(nullptr, &result[0], pathMax) != 0)
|
||||
exePathTemp = Utils::String::wideStringToString(result);
|
||||
exePath = Utils::String::wideStringToString(result);
|
||||
#else
|
||||
std::string result(pathMax, 0);
|
||||
if (readlink("/proc/self/exe", &result[0], pathMax) != -1)
|
||||
exePathTemp = result;
|
||||
exePath = result;
|
||||
#endif
|
||||
exePathTemp.erase(std::find(exePathTemp.begin(), exePathTemp.end(), '\0'),
|
||||
exePathTemp.end());
|
||||
esBinary = exePathTemp;
|
||||
exePath = exePathTemp;
|
||||
exePath = getCanonicalPathSTD(exePath);
|
||||
exePath.erase(std::find(exePath.begin(), exePath.end(), '\0'), exePath.end());
|
||||
esBinary = exePath;
|
||||
exePath = getCanonicalPath(exePath);
|
||||
|
||||
// Fallback to argv[0] if everything else fails.
|
||||
if (exePath.empty()) {
|
||||
esBinary = path;
|
||||
exePath = getCanonicalPathSTD(esBinary);
|
||||
exePath = getCanonicalPath(path);
|
||||
}
|
||||
|
||||
if (isRegularFileSTD(exePath))
|
||||
exePath = exePath.parent_path();
|
||||
if (isRegularFile(exePath))
|
||||
exePath = getParent(exePath);
|
||||
|
||||
#if defined(APPIMAGE_BUILD)
|
||||
// We need to check that the APPIMAGE variable is available as the APPIMAGE_BUILD
|
||||
// build flag could have been passed without running as an actual AppImage.
|
||||
if (getenv("APPIMAGE") != nullptr)
|
||||
esBinary = std::filesystem::path {getenv("APPIMAGE")};
|
||||
esBinary = getenv("APPIMAGE");
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string getExePath()
|
||||
{
|
||||
// Return executable path.
|
||||
return exePath.string();
|
||||
}
|
||||
|
||||
std::filesystem::path getExePathSTD()
|
||||
{
|
||||
// Return executable path.
|
||||
return exePath;
|
||||
}
|
||||
|
||||
std::string getEsBinary()
|
||||
{
|
||||
// Return the absolute path to the ES-DE binary.
|
||||
return esBinary.string();
|
||||
}
|
||||
|
||||
std::filesystem::path getEsBinarySTD()
|
||||
{
|
||||
// Return the absolute path to the ES-DE binary.
|
||||
return esBinary;
|
||||
}
|
||||
|
||||
std::filesystem::path getProgramDataPath()
|
||||
std::string getProgramDataPath()
|
||||
{
|
||||
#if defined(__ANDROID__)
|
||||
return AndroidVariables::sInternalDataDirectory;
|
||||
#elif defined(__unix__)
|
||||
return std::filesystem::path {installPrefix}.append("share").append("es-de");
|
||||
return installPrefix + "/share/es-de";
|
||||
#else
|
||||
return std::filesystem::path {};
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -554,9 +483,6 @@ namespace Utils
|
|||
|
||||
std::string getCanonicalPath(const std::string& path)
|
||||
{
|
||||
if (path.empty())
|
||||
return "";
|
||||
|
||||
// Hack for builtin resources.
|
||||
if ((path[0] == ':') && (path[1] == '/'))
|
||||
return path;
|
||||
|
@ -617,18 +543,6 @@ namespace Utils
|
|||
return canonicalPath;
|
||||
}
|
||||
|
||||
std::filesystem::path getCanonicalPathSTD(const std::filesystem::path& path)
|
||||
{
|
||||
if (path.empty())
|
||||
return path;
|
||||
|
||||
// Hack for builtin resources.
|
||||
if ((path.string()[0] == ':') && (path.string()[1] == '/'))
|
||||
return path;
|
||||
|
||||
return std::filesystem::canonical(path);
|
||||
}
|
||||
|
||||
std::string getAbsolutePath(const std::string& path, const std::string& base)
|
||||
{
|
||||
const std::string& absolutePath {getGenericPath(path)};
|
||||
|
@ -666,11 +580,6 @@ namespace Utils
|
|||
return genericPath;
|
||||
}
|
||||
|
||||
std::filesystem::path getFileNameSTD(const std::filesystem::path& path)
|
||||
{
|
||||
return path.filename();
|
||||
}
|
||||
|
||||
std::string getStem(const std::string& path)
|
||||
{
|
||||
std::string fileName {getFileName(path)};
|
||||
|
@ -915,7 +824,7 @@ namespace Utils
|
|||
bool createEmptyFile(const std::filesystem::path& path)
|
||||
{
|
||||
const std::filesystem::path cleanPath {path.lexically_normal().make_preferred()};
|
||||
if (existsSTD(path)) {
|
||||
if (exists(path)) {
|
||||
LOG(LogError) << "Couldn't create target file \"" << cleanPath.string()
|
||||
<< "\" as it already exists";
|
||||
return false;
|
||||
|
@ -1023,22 +932,6 @@ namespace Utils
|
|||
}
|
||||
}
|
||||
|
||||
bool existsSTD(const std::filesystem::path& path)
|
||||
{
|
||||
const std::string& genericPath {getGenericPath(path.string())};
|
||||
try {
|
||||
#if defined(_WIN64)
|
||||
return std::filesystem::exists(Utils::String::stringToWideString(genericPath));
|
||||
#else
|
||||
return std::filesystem::exists(genericPath);
|
||||
#endif
|
||||
}
|
||||
catch (std::filesystem::filesystem_error& error) {
|
||||
LOG(LogError) << "FileSystemUtil::exists(): " << error.what();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool driveExists(const std::string& path)
|
||||
{
|
||||
#if defined(_WIN64)
|
||||
|
@ -1088,17 +981,6 @@ namespace Utils
|
|||
}
|
||||
}
|
||||
|
||||
bool isRegularFileSTD(const std::filesystem::path& path)
|
||||
{
|
||||
try {
|
||||
return std::filesystem::is_regular_file(path);
|
||||
}
|
||||
catch (std::filesystem::filesystem_error& error) {
|
||||
LOG(LogError) << "FileSystemUtil::isRegularFile(): " << error.what();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isDirectory(const std::string& path)
|
||||
{
|
||||
const std::string& genericPath {getGenericPath(path)};
|
||||
|
@ -1116,17 +998,6 @@ namespace Utils
|
|||
}
|
||||
}
|
||||
|
||||
bool isDirectorySTD(const std::filesystem::path& path)
|
||||
{
|
||||
try {
|
||||
return std::filesystem::is_directory(path);
|
||||
}
|
||||
catch (std::filesystem::filesystem_error& error) {
|
||||
LOG(LogError) << "FileSystemUtil::isDirectory(): " << error.what();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isSymlink(const std::string& path)
|
||||
{
|
||||
const std::string& genericPath {getGenericPath(path)};
|
||||
|
@ -1143,17 +1014,6 @@ namespace Utils
|
|||
}
|
||||
}
|
||||
|
||||
bool isSymlinkSTD(const std::filesystem::path& path)
|
||||
{
|
||||
try {
|
||||
return std::filesystem::is_symlink(path);
|
||||
}
|
||||
catch (std::filesystem::filesystem_error& error) {
|
||||
LOG(LogError) << "FileSystemUtil::isSymlink(): " << error.what();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isHidden(const std::string& path)
|
||||
{
|
||||
const std::string& genericPath {getGenericPath(path)};
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
class FileSystemVariables
|
||||
{
|
||||
public:
|
||||
static inline std::filesystem::path sAppDataDirectory;
|
||||
static inline std::string sAppDataDirectory;
|
||||
};
|
||||
|
||||
namespace Utils
|
||||
|
@ -26,36 +26,29 @@ namespace Utils
|
|||
namespace FileSystem
|
||||
{
|
||||
using StringList = std::list<std::string>;
|
||||
using FileList = std::list<std::filesystem::path>;
|
||||
|
||||
StringList getDirContent(const std::string& path, const bool recursive = false);
|
||||
FileList getDirContentSTD(const std::filesystem::path& path, const bool recursive = false);
|
||||
StringList getMatchingFiles(const std::string& pattern);
|
||||
StringList getPathList(const std::string& path);
|
||||
void setHomePath(const std::string& path);
|
||||
std::string getHomePath();
|
||||
std::filesystem::path getHomePathSTD();
|
||||
std::string getAppDataDirectory();
|
||||
std::string getInternalAppDataDirectory();
|
||||
std::string getSystemHomeDirectory();
|
||||
std::filesystem::path getAppDataDirectory();
|
||||
std::filesystem::path getInternalAppDataDirectory();
|
||||
std::string getCWDPath();
|
||||
std::string getPathToBinary(const std::string& executable);
|
||||
void setExePath(const std::string& path);
|
||||
std::string getExePath();
|
||||
std::filesystem::path getExePathSTD();
|
||||
std::string getEsBinary();
|
||||
std::filesystem::path getEsBinarySTD();
|
||||
std::filesystem::path getProgramDataPath();
|
||||
std::string getProgramDataPath();
|
||||
std::string getPreferredPath(const std::string& path);
|
||||
std::string getGenericPath(const std::string& path);
|
||||
std::string getEscapedPath(const std::string& path);
|
||||
std::string getCanonicalPath(const std::string& path);
|
||||
std::filesystem::path getCanonicalPathSTD(const std::filesystem::path& path);
|
||||
std::string getAbsolutePath(
|
||||
const std::string& path,
|
||||
const std::string& base = std::filesystem::current_path().string());
|
||||
std::string getAbsolutePath(const std::string& path,
|
||||
const std::string& base = getCWDPath());
|
||||
std::string getParent(const std::string& path);
|
||||
std::string getFileName(const std::string& path);
|
||||
std::filesystem::path getFileNameSTD(const std::filesystem::path& path);
|
||||
std::string getStem(const std::string& path);
|
||||
std::string getExtension(const std::string& path);
|
||||
long getFileSize(const std::filesystem::path& path);
|
||||
|
@ -81,15 +74,11 @@ namespace Utils
|
|||
bool removeDirectory(const std::string& path, bool recursive);
|
||||
bool createDirectory(const std::string& path);
|
||||
bool exists(const std::string& path);
|
||||
bool existsSTD(const std::filesystem::path& path);
|
||||
bool driveExists(const std::string& path);
|
||||
bool isAbsolute(const std::string& path);
|
||||
bool isRegularFile(const std::string& path);
|
||||
bool isRegularFileSTD(const std::filesystem::path& path);
|
||||
bool isDirectory(const std::string& path);
|
||||
bool isDirectorySTD(const std::filesystem::path& path);
|
||||
bool isSymlink(const std::string& path);
|
||||
bool isSymlinkSTD(const std::filesystem::path& path);
|
||||
bool isHidden(const std::string& path);
|
||||
|
||||
} // namespace FileSystem
|
||||
|
|
Loading…
Reference in a new issue