File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 44
55#include < fstream>
66#include < iostream>
7- #include < iterator>
87#include < utility>
98
109namespace
@@ -45,13 +44,18 @@ namespace
4544
4645 bool loadFileContents (const std::filesystem::path& sourcefilePath, std::string& destination)
4746 {
48- std::ifstream file { sourcefilePath };
49- if (file. is_open () )
47+ std::ifstream file { sourcefilePath, std::ios_base::binary };
48+ if (file)
5049 {
51- destination = { std::istreambuf_iterator<char > { file }, std::istreambuf_iterator<char > {} };
50+ const std::uintmax_t size = std::filesystem::file_size (sourcefilePath);
51+ if (size > 0 )
52+ {
53+ destination.resize (static_cast <std::size_t >(size));
54+ file.read (destination.data (), static_cast <std::streamsize>(size));
55+ }
56+ return true ;
5257 }
53-
54- return file.is_open ();
58+ return false ;
5559 }
5660} // namespace
5761
You can’t perform that action at this time.
0 commit comments