Reverted binary file openings in some cases where it causes Windows line breaks to not get converted to standard format

This commit is contained in:
Leon Styhre 2023-08-10 23:13:55 +02:00
parent de4bd7341f
commit cf065e8935
3 changed files with 12 additions and 13 deletions

View file

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

View file

@ -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 \""

View file

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