MCPcopy Create free account
hub / github.com/VCVRack/Rack / readFile

Function readFile

src/system.cpp:301–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299
300
301std::vector<uint8_t> readFile(const std::string& path) {
302 std::vector<uint8_t> data;
303 FILE* f = std::fopen(path.c_str(), "rb");
304 if (!f)
305 throw Exception("Cannot read file %s", path.c_str());
306 DEFER({
307 std::fclose(f);
308 });
309
310 // Get file size so we can make a single allocation
311 std::fseek(f, 0, SEEK_END);
312 size_t len = std::ftell(f);
313 std::fseek(f, 0, SEEK_SET);
314
315 data.resize(len);
316 std::fread(data.data(), 1, len, f);
317 return data;
318}
319
320
321uint8_t* readFile(const std::string& path, size_t* size) {

Callers 1

loadFileMethod · 0.85

Calls 1

ExceptionClass · 0.85

Tested by

no test coverage detected