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

Method copyTree

3ds/source/io.cpp:298–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296}
297
298Result io::copyTree(FS_Archive srcArch, FS_Archive dstArch, const std::u16string& srcRoot, const std::u16string& dstRoot,
299 const std::vector<TreeEntry>& entries, ProgressSink& sink)
300{
301 // One scratch buffer for every file in the tree instead of a per-file new/delete.
302 auto buf = std::make_unique<u8[]>(BUFFER_SIZE);
303 Result res = 0;
304
305 for (const auto& entry : entries) {
306 if (sink.cancelled()) {
307 break;
308 }
309 std::u16string dst = dstRoot + entry.rel;
310 if (entry.folder) {
311 res = io::createDirectory(dstArch, dst);
312 // An existing directory is as good as a new one.
313 if (R_FAILED(res) && (u32)res != RES_FS_DIR_EXISTS) {
314 return res;
315 }
316 res = 0;
317 }
318 else {
319 res = io::copyFile(srcArch, dstArch, srcRoot + entry.rel, dst, sink, buf.get());
320 if (R_FAILED(res)) {
321 return res;
322 }
323 }
324 }
325
326 return res;
327}
328
329Result io::createDirectory(FS_Archive archive, const std::u16string& path)
330{

Callers

nothing calls this directly

Calls 2

cancelledMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected