| 268 | } |
| 269 | |
| 270 | bool FileSystem::loadContent(PathId fileId, std::vector<char> &content) { |
| 271 | if (!fileId) return false; |
| 272 | |
| 273 | bool result = false; |
| 274 | std::streamsize length = 0; |
| 275 | if (filesize(fileId, &length)) { |
| 276 | std::istream &strm = openForLoad(fileId); |
| 277 | if (strm.good()) { |
| 278 | content.resize(length); |
| 279 | |
| 280 | std::streamsize offset = 0; |
| 281 | while (!strm.eof() && (offset < length)) { |
| 282 | strm.read(content.data() + offset, length - offset); |
| 283 | offset += strm.gcount(); |
| 284 | } |
| 285 | result = offset == length; |
| 286 | } |
| 287 | close(strm); |
| 288 | } |
| 289 | return result; |
| 290 | } |
| 291 | |
| 292 | bool FileSystem::saveContent(PathId fileId, const char *content, |
| 293 | std::streamsize length) { |