MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / write_file

Method write_file

src/jit/impl/utils.cpp:225–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223} // anonymous namespace
224
225void ExecutableHelper::write_file(const std::string& name, const std::string& data) {
226 auto full_name = realpath(name);
227 FILE* fptr = fopen(full_name.c_str(), "wb");
228 mgb_throw_if(
229 !fptr, SystemError, "failed to open %s: %s", full_name.c_str(),
230 strerror(errno));
231 std::unique_ptr<FILE, int (*)(FILE*)> fptr_close{fptr, ::fclose};
232 auto done = fwrite(data.data(), 1, data.size(), fptr);
233 mgb_throw_if(
234 done != data.size(), SystemError,
235 "failed to write file: req=%zu written=%zu: %s", data.size(), done,
236 strerror(errno));
237 fptr_close.release();
238 int err = fclose(fptr);
239 mgb_throw_if(err, SystemError, "failed to close file: %s", strerror(errno));
240}
241
242ExecutableHelper& ::ExecutableHelper::get() {
243 static ExecutableHelperImpl inst;

Callers 1

codegen_cudaMethod · 0.80

Calls 3

dataMethod · 0.45
sizeMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected