From 08d6e1f23f725419f2ad5e1df1cd396a3bf6a141 Mon Sep 17 00:00:00 2001 From: flb Date: Wed, 7 Sep 2022 20:41:16 +0200 Subject: [PATCH] Account carriage returns when processing files (closes https://github.com/HamletDuFromage/aio-switch-updater/issues/210) --- source/extract.cpp | 2 +- source/fs.cpp | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/source/extract.cpp b/source/extract.cpp index eab3b76..58e2fa7 100644 --- a/source/extract.cpp +++ b/source/extract.cpp @@ -114,7 +114,7 @@ namespace extract { } if (appPath != filename) { if ((overwriteInis == 0 && filename.substr(filename.length() - 4) == ".ini") || std::find_if(ignoreList.begin(), ignoreList.end(), [&filename](std::string ignored) { - u8 res = (filename).find(ignored); + u8 res = filename.find(ignored); return (res == 0 || res == 1); }) != ignoreList.end()) { if (!std::filesystem::exists(filename)) { extractEntry(filename, zfile); diff --git a/source/fs.cpp b/source/fs.cpp index 07a91b3..0f7d61b 100644 --- a/source/fs.cpp +++ b/source/fs.cpp @@ -106,16 +106,19 @@ namespace fs { std::set readLineByLine(const std::string& path) { - std::set titles; - std::string str; - std::ifstream in(path); - if (in) { - while (std::getline(in, str)) { - if (str.size() > 0) - titles.insert(str); + std::set res; + std::ifstream lines(path); + std::string line; + if (lines) { + while (std::getline(lines, line)) { + if (line.size() > 0) { + if (line.back() == '\r') + line.pop_back(); + res.insert(line); + } } } - return titles; + return res; } Result getFreeStorageSD(s64& free)