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