| 476 | } |
| 477 | |
| 478 | static 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 | } |
| 497 | static 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 | |