Mercurial > minori
comparison dep/animia/src/util.cc @ 161:71752dcbb49f
junk: clunky merge commit
maybe I should enable rebase on this repo
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Fri, 17 Nov 2023 13:09:20 -0500 |
parents | 80d6b28eb29f |
children |
comparison
equal
deleted
inserted
replaced
160:900b5b530883 | 161:71752dcbb49f |
---|---|
8 | 8 |
9 namespace animia::internal::util { | 9 namespace animia::internal::util { |
10 | 10 |
11 bool ReadFile(const std::string& path, std::string& data) { | 11 bool ReadFile(const std::string& path, std::string& data) { |
12 std::ifstream file(path.c_str(), std::ios::in | std::ios::binary); | 12 std::ifstream file(path.c_str(), std::ios::in | std::ios::binary); |
13 | |
14 if (!file) | 13 if (!file) |
15 return false; | 14 return false; |
16 | 15 |
17 file.seekg(0, std::ios::end); | 16 std::ostringstream string; |
18 data.resize(static_cast<size_t>(file.tellg())); | 17 string << file.rdbuf(); |
19 file.seekg(0, std::ios::beg); | 18 file.close(); |
20 | 19 |
21 file.read(&data.front(), data.size()); | 20 data = string.str(); |
22 file.close(); | |
23 | 21 |
24 return true; | 22 return true; |
25 } | 23 } |
26 | 24 |
27 /* this assumes ASCII... which really should be the case for what we need, anyway */ | 25 /* this assumes ASCII... which really should be the case for what we need, anyway */ |