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

Method write_file

components/filesystem/src/std_filesystem.cpp:112–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void StdFileSystem::write_file(const Path &path, const std::vector<uint8_t> &data)
113{
114 // create directory if it doesn't exist
115 auto parent = path.parent_path();
116 if (!std::filesystem::exists(parent))
117 {
118 create_directory(parent);
119 }
120
121 std::ofstream file{path, std::ios::binary | std::ios::trunc};
122
123 if (!file.is_open())
124 {
125 throw std::runtime_error("Failed to open file for writing at path: " + path.string());
126 }
127
128 file.write(reinterpret_cast<const char *>(data.data()), data.size());
129}
130
131void StdFileSystem::remove(const Path &path)
132{

Callers

nothing calls this directly

Calls 2

create_directoryFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected