MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / read_chunk

Method read_chunk

components/filesystem/src/std_filesystem.cpp:88–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88std::vector<uint8_t> StdFileSystem::read_chunk(const Path &path, size_t offset, size_t count)
89{
90 std::ifstream file{path, std::ios::binary | std::ios::ate};
91
92 if (!file.is_open())
93 {
94 throw std::runtime_error("Failed to open file for reading at path: " + path.string());
95 }
96
97 auto size = stat_file(path).size;
98
99 if (offset + count > size)
100 {
101 return {};
102 }
103
104 // read file contents
105 file.seekg(offset, std::ios::beg);
106 std::vector<uint8_t> data(count);
107 file.read(reinterpret_cast<char *>(data.data()), count);
108
109 return data;
110}
111
112void StdFileSystem::write_file(const Path &path, const std::vector<uint8_t> &data)
113{

Callers 1

AstcMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected