MCPcopy Create free account
hub / github.com/bdring/FluidNC / copyFile

Function copyFile

FluidNC/src/FileCommands.cpp:478–496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

476}
477
478static Error copyFile(const Volume& ifs, const char* ipath, const Volume& ofs, const char* opath, Channel& out) { // No ESP command
479 std::filesystem::path filepath;
480 try {
481 FileStream outFile { opath, "w", ofs };
482 FileStream inFile { ipath, "r", ifs };
483 uint8_t buf[512];
484 size_t len;
485 while ((len = inFile.read(buf, 512)) > 0) {
486 outFile.write(buf, len);
487 }
488 filepath = outFile.fpath();
489 } catch (const Error err) {
490 log_error_to(out, "Cannot create file " << opath);
491 return Error::FsFailedCreateFile;
492 }
493 // Rehash after outFile goes out of scope
494 HashFS::rehash_file(filepath);
495 return Error::Ok;
496}
497static Error copyDir(const Volume& ifs, const std::string_view iDir, const Volume& ofs, const std::string_view oDir, Channel& out) { // No ESP command
498 std::error_code ec;
499

Callers 1

copyDirFunction · 0.85

Calls 3

fpathMethod · 0.80
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected