mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-12-01 10:35:38 +00:00
Changed a number of stream operations to open files in binary mode to always get proper Unix line breaks
This commit is contained in:
parent
b218c4806b
commit
de4bd7341f
|
@ -155,9 +155,10 @@ void CollectionSystemsManager::saveCustomCollection(SystemData* sys)
|
||||||
|
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
configFileIn.open(
|
configFileIn.open(
|
||||||
Utils::String::stringToWideString(getCustomCollectionConfigPath(name)).c_str());
|
Utils::String::stringToWideString(getCustomCollectionConfigPath(name)).c_str(),
|
||||||
|
std::ios::binary);
|
||||||
#else
|
#else
|
||||||
configFileIn.open(getCustomCollectionConfigPath(name));
|
configFileIn.open(getCustomCollectionConfigPath(name), std::ios::binary);
|
||||||
#endif
|
#endif
|
||||||
for (std::string gameEntry; getline(configFileIn, gameEntry);) {
|
for (std::string gameEntry; getline(configFileIn, gameEntry);) {
|
||||||
std::string gamePath {Utils::String::replace(gameEntry, "%ROMPATH%", rompath)};
|
std::string gamePath {Utils::String::replace(gameEntry, "%ROMPATH%", rompath)};
|
||||||
|
@ -187,9 +188,10 @@ void CollectionSystemsManager::saveCustomCollection(SystemData* sys)
|
||||||
|
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
configFileOut.open(
|
configFileOut.open(
|
||||||
Utils::String::stringToWideString(getCustomCollectionConfigPath(name)).c_str());
|
Utils::String::stringToWideString(getCustomCollectionConfigPath(name)).c_str(),
|
||||||
|
std::ios::binary);
|
||||||
#else
|
#else
|
||||||
configFileOut.open(getCustomCollectionConfigPath(name));
|
configFileOut.open(getCustomCollectionConfigPath(name), std::ios::binary);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (auto it = fileGameEntries.cbegin(); it != fileGameEntries.cend(); ++it)
|
for (auto it = fileGameEntries.cbegin(); it != fileGameEntries.cend(); ++it)
|
||||||
|
@ -1035,9 +1037,9 @@ void CollectionSystemsManager::reactivateCustomCollectionEntry(FileData* game)
|
||||||
std::string path {getCustomCollectionConfigPath(it->first)};
|
std::string path {getCustomCollectionConfigPath(it->first)};
|
||||||
if (Utils::FileSystem::exists(path)) {
|
if (Utils::FileSystem::exists(path)) {
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
std::ifstream input(Utils::String::stringToWideString(path).c_str());
|
std::ifstream input {Utils::String::stringToWideString(path).c_str(), std::ios::binary};
|
||||||
#else
|
#else
|
||||||
std::ifstream input(path);
|
std::ifstream input {path, std::ios::binary};
|
||||||
#endif
|
#endif
|
||||||
for (std::string gameKey; getline(input, gameKey);) {
|
for (std::string gameKey; getline(input, gameKey);) {
|
||||||
if (gameKey == gamePath) {
|
if (gameKey == gamePath) {
|
||||||
|
@ -1283,9 +1285,9 @@ void CollectionSystemsManager::populateCustomCollection(CollectionSystemData* sy
|
||||||
// Get configuration for this custom collection.
|
// Get configuration for this custom collection.
|
||||||
|
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
std::ifstream input(Utils::String::stringToWideString(path).c_str());
|
std::ifstream input {Utils::String::stringToWideString(path).c_str(), std::ios::binary};
|
||||||
#else
|
#else
|
||||||
std::ifstream input(path);
|
std::ifstream input {path, std::ios::binary};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get all files map.
|
// Get all files map.
|
||||||
|
|
|
@ -726,9 +726,10 @@ void GuiOrphanedDataCleanup::cleanupCollections()
|
||||||
std::ifstream configFileSource;
|
std::ifstream configFileSource;
|
||||||
|
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
configFileSource.open(Utils::String::stringToWideString(collectionFile).c_str());
|
configFileSource.open(Utils::String::stringToWideString(collectionFile).c_str(),
|
||||||
|
std::ios::binary);
|
||||||
#else
|
#else
|
||||||
configFileSource.open(collectionFile);
|
configFileSource.open(collectionFile, std::ios::binary);
|
||||||
#endif
|
#endif
|
||||||
if (!configFileSource.good()) {
|
if (!configFileSource.good()) {
|
||||||
LOG(LogError) << "Couldn't open custom collection configuration file \""
|
LOG(LogError) << "Couldn't open custom collection configuration file \""
|
||||||
|
|
|
@ -146,7 +146,7 @@ bool TheGamesDBJSONRequestResources::saveResource(HttpReq* req,
|
||||||
|
|
||||||
ensureScrapersResourcesDir();
|
ensureScrapersResourcesDir();
|
||||||
|
|
||||||
std::ofstream fout {file_name};
|
std::ofstream fout {file_name, std::ios::binary};
|
||||||
fout << req->getContent();
|
fout << req->getContent();
|
||||||
fout.close();
|
fout.close();
|
||||||
loadResource(resource, resource_name, file_name);
|
loadResource(resource, resource_name, file_name);
|
||||||
|
@ -165,7 +165,7 @@ int TheGamesDBJSONRequestResources::loadResource(std::unordered_map<int, std::st
|
||||||
const std::string& resource_name,
|
const std::string& resource_name,
|
||||||
const std::string& file_name)
|
const std::string& file_name)
|
||||||
{
|
{
|
||||||
std::ifstream fin {file_name};
|
std::ifstream fin {file_name, std::ios::binary};
|
||||||
if (!fin.good())
|
if (!fin.good())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,7 @@ namespace Utils
|
||||||
Utils::Platform::runSystemCommand("flatpak-spawn --host which " + *it + "/" +
|
Utils::Platform::runSystemCommand("flatpak-spawn --host which " + *it + "/" +
|
||||||
executable + " > " + tempFile + " 2>/dev/null");
|
executable + " > " + tempFile + " 2>/dev/null");
|
||||||
std::ifstream tempFileStream;
|
std::ifstream tempFileStream;
|
||||||
tempFileStream.open(tempFile);
|
tempFileStream.open(tempFile, std::ios::binary);
|
||||||
getline(tempFileStream, emulatorPath);
|
getline(tempFileStream, emulatorPath);
|
||||||
tempFileStream.close();
|
tempFileStream.close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue