From cf065e8935bfa20f8fd961fa043d71f6fbd6adb5 Mon Sep 17 00:00:00 2001 From: Leon Styhre <leon@leonstyhre.com> Date: Thu, 10 Aug 2023 23:13:55 +0200 Subject: [PATCH] Reverted binary file openings in some cases where it causes Windows line breaks to not get converted to standard format --- es-app/src/CollectionSystemsManager.cpp | 13 ++++++------- es-app/src/guis/GuiOrphanedDataCleanup.cpp | 10 +++++----- es-app/src/scrapers/GamesDBJSONScraperResources.cpp | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/es-app/src/CollectionSystemsManager.cpp b/es-app/src/CollectionSystemsManager.cpp index 3f22b5154..08bbc6e73 100644 --- a/es-app/src/CollectionSystemsManager.cpp +++ b/es-app/src/CollectionSystemsManager.cpp @@ -155,10 +155,9 @@ void CollectionSystemsManager::saveCustomCollection(SystemData* sys) #if defined(_WIN64) configFileIn.open( - Utils::String::stringToWideString(getCustomCollectionConfigPath(name)).c_str(), - std::ios::binary); + Utils::String::stringToWideString(getCustomCollectionConfigPath(name)).c_str()); #else - configFileIn.open(getCustomCollectionConfigPath(name), std::ios::binary); + configFileIn.open(getCustomCollectionConfigPath(name)); #endif for (std::string gameEntry; getline(configFileIn, gameEntry);) { std::string gamePath {Utils::String::replace(gameEntry, "%ROMPATH%", rompath)}; @@ -1037,9 +1036,9 @@ void CollectionSystemsManager::reactivateCustomCollectionEntry(FileData* game) std::string path {getCustomCollectionConfigPath(it->first)}; if (Utils::FileSystem::exists(path)) { #if defined(_WIN64) - std::ifstream input {Utils::String::stringToWideString(path).c_str(), std::ios::binary}; + std::ifstream input {Utils::String::stringToWideString(path).c_str()}; #else - std::ifstream input {path, std::ios::binary}; + std::ifstream input {path}; #endif for (std::string gameKey; getline(input, gameKey);) { if (gameKey == gamePath) { @@ -1285,9 +1284,9 @@ void CollectionSystemsManager::populateCustomCollection(CollectionSystemData* sy // Get configuration for this custom collection. #if defined(_WIN64) - std::ifstream input {Utils::String::stringToWideString(path).c_str(), std::ios::binary}; + std::ifstream input {Utils::String::stringToWideString(path).c_str()}; #else - std::ifstream input {path, std::ios::binary}; + std::ifstream input {path}; #endif // Get all files map. diff --git a/es-app/src/guis/GuiOrphanedDataCleanup.cpp b/es-app/src/guis/GuiOrphanedDataCleanup.cpp index 0baf86426..64d02c7d8 100644 --- a/es-app/src/guis/GuiOrphanedDataCleanup.cpp +++ b/es-app/src/guis/GuiOrphanedDataCleanup.cpp @@ -726,10 +726,9 @@ void GuiOrphanedDataCleanup::cleanupCollections() std::ifstream configFileSource; #if defined(_WIN64) - configFileSource.open(Utils::String::stringToWideString(collectionFile).c_str(), - std::ios::binary); + configFileSource.open(Utils::String::stringToWideString(collectionFile).c_str()); #else - configFileSource.open(collectionFile, std::ios::binary); + configFileSource.open(collectionFile); #endif if (!configFileSource.good()) { LOG(LogError) << "Couldn't open custom collection configuration file \"" @@ -807,9 +806,10 @@ void GuiOrphanedDataCleanup::cleanupCollections() else { std::ofstream configFileTarget; #if defined(_WIN64) - configFileTarget.open(Utils::String::stringToWideString(tempFile).c_str()); + configFileTarget.open(Utils::String::stringToWideString(tempFile).c_str(), + std::ios::binary); #else - configFileTarget.open(tempFile); + configFileTarget.open(tempFile, std::ios::binary); #endif if (!configFileTarget.good()) { LOG(LogError) << "Couldn't write to temporary collection configuration file \"" diff --git a/es-app/src/scrapers/GamesDBJSONScraperResources.cpp b/es-app/src/scrapers/GamesDBJSONScraperResources.cpp index 372ea5453..161c30cd9 100644 --- a/es-app/src/scrapers/GamesDBJSONScraperResources.cpp +++ b/es-app/src/scrapers/GamesDBJSONScraperResources.cpp @@ -165,7 +165,7 @@ int TheGamesDBJSONRequestResources::loadResource(std::unordered_map<int, std::st const std::string& resource_name, const std::string& file_name) { - std::ifstream fin {file_name, std::ios::binary}; + std::ifstream fin {file_name}; if (!fin.good()) return 1;