--- a/src/FileAttributeFinder.h Fri Jul 26 22:34:30 2019 +0200
+++ b/src/FileAttributeFinder.h Fri Jul 26 22:50:35 2019 +0200
@@ -73,17 +73,18 @@
}
string_t getContent(const fs::path& file) {
- // TODO: better copy
- // not working:
- wifstream source(file);
- std::wstringstream result;
- for (wchar_t ch; source.get(ch); source.good()) result << ch;
- return result.str();
+ try {
+ ifstream input(file);
+ std::stringstream bytes;
+ bytes << input.rdbuf();
- //wifstream stream(file);
- //std::wstringstream content;
- //content << stream.rdbuf();
- //return content.str();
+ // TODO: optional whitespace trimming or substring
+ // TODO: custom encoding + read encoding from xattr
+ return convertor.from_bytes(bytes.str());
+ } catch (const std::range_error& e) {
+ // TODO: allow custom error value or fallback to HEX/Base64
+ return L"";
+ }
}
protected: