MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / savWrite

Method savWrite

3ds/source/script/scripthost.cpp:307–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305 }
306
307 int savWrite(int handle, const char* path, const void* data, size_t size) override
308 {
309 // Create/replace: the create-on-open path keeps an existing file's size,
310 // so drop it first (a missing file fails harmlessly).
311 const std::u16string p = archivePath(path);
312 FSUSER_DeleteFile(mSlots[handle].arch.fs(), fsMakePath(PATH_UTF16, p.data()));
313
314 FSStream stream(mSlots[handle].arch.fs(), p, FS_OPEN_WRITE, (u32)size);
315 if (!stream.good()) {
316 const Result res = stream.result();
317 stream.close();
318 return (int)res;
319 }
320
321 const u32 written = stream.write(data, (u32)size);
322 const Result res = stream.result();
323 stream.close();
324 return written == (u32)size ? 0 : (R_FAILED(res) ? (int)res : -3);
325 }
326
327 int savDelete(int handle, const char* path) override
328 {

Callers 1

ckpt_sav_writeFunction · 0.45

Calls 7

archivePathFunction · 0.85
fsMethod · 0.80
resultMethod · 0.80
dataMethod · 0.45
goodMethod · 0.45
closeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected