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

Method savWrite

3ds/source/script/scripthost.cpp:202–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200 }
201
202 int savWrite(int handle, const char* path, const void* data, size_t size) override
203 {
204 // Create/replace: the create-on-open path keeps an existing file's size,
205 // so drop it first (a missing file fails harmlessly).
206 const std::u16string p = archivePath(path);
207 FSUSER_DeleteFile(mSlots[handle].arch.fs(), fsMakePath(PATH_UTF16, p.data()));
208
209 FSStream stream(mSlots[handle].arch.fs(), p, FS_OPEN_WRITE, (u32)size);
210 if (!stream.good()) {
211 const Result res = stream.result();
212 stream.close();
213 return (int)res;
214 }
215
216 const u32 written = stream.write(data, (u32)size);
217 const Result res = stream.result();
218 stream.close();
219 return written == (u32)size ? 0 : (R_FAILED(res) ? (int)res : -3);
220 }
221
222 int savDelete(int handle, const char* path) override
223 {

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