Mercurial > minori
comparison dep/animia/src/util.cc @ 158:80d6b28eb29f
dep/animia: fix most X11 stuff
it looks like _NET_WM_PID isn't supported by MOST clients, or my code is wrong...
core/filesystem: fix Linux config path handling on *nix
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Fri, 17 Nov 2023 02:07:33 -0500 |
| parents | cdf79282d647 |
| children |
comparison
equal
deleted
inserted
replaced
| 157:18c8eb5d1edc | 158:80d6b28eb29f |
|---|---|
| 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 */ |
