MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / read_file

Function read_file

src/framework/assets/torch_bin.cpp:28–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28std::vector<uint8_t> read_file(const std::filesystem::path & path) {
29 std::ifstream stream(path, std::ios::binary | std::ios::ate);
30 if (!stream) {
31 throw std::runtime_error("torch .bin cannot be opened: " + path.string());
32 }
33 const std::streamsize size = stream.tellg();
34 if (size < 0) {
35 throw std::runtime_error("torch .bin has an invalid size: " + path.string());
36 }
37 stream.seekg(0);
38 std::vector<uint8_t> bytes(static_cast<size_t>(size));
39 if (size > 0 && !stream.read(reinterpret_cast<char *>(bytes.data()), size)) {
40 throw std::runtime_error("torch .bin could not be read: " + path.string());
41 }
42 return bytes;
43}
44
45// ---- Minimal STORED-only ZIP reader -------------------------------------------------
46

Callers 1

TorchBinTensorSourceMethod · 0.70

Calls 2

readMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected