MCPcopy Create free account
hub / github.com/chipsalliance/Surelog / loadContent

Method loadContent

src/Common/FileSystem.cpp:270–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270bool 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
292bool FileSystem::saveContent(PathId fileId, const char *content,
293 std::streamsize length) {

Callers 1

TESTFunction · 0.80

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.64