MCPcopy Create free account
hub / github.com/apache/arrow / Move

Method Move

cpp/src/arrow/filesystem/mockfs.cc:661–693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

659} // namespace
660
661Status MockFileSystem::Move(const std::string& src, const std::string& dest) {
662 return BinaryOp::Run(impl_.get(), src, dest, [&](const BinaryOp& op) -> Status {
663 if (op.src_entry == nullptr) {
664 return PathNotFound(src);
665 }
666 if (op.dest_entry != nullptr) {
667 if (op.dest_entry->is_dir()) {
668 return Status::IOError("Cannot replace destination '", dest,
669 "', which is a directory");
670 }
671 if (op.dest_entry->is_file() && op.src_entry->is_dir()) {
672 return Status::IOError("Cannot replace destination '", dest,
673 "', which is a file, with directory '", src, "'");
674 }
675 }
676 if (op.src_parts.size() < op.dest_parts.size()) {
677 // Check if dest is a child of src
678 auto p =
679 std::mismatch(op.src_parts.begin(), op.src_parts.end(), op.dest_parts.begin());
680 if (p.first == op.src_parts.end()) {
681 return Status::IOError("Cannot move '", src, "' into child path '", dest, "'");
682 }
683 }
684
685 // Move original entry, fix its name
686 std::unique_ptr<Entry> new_entry(new Entry(std::move(*op.src_entry)));
687 new_entry->SetName(op.dest_name);
688 bool deleted = op.src_dir.DeleteEntry(op.src_name);
689 DCHECK(deleted);
690 op.dest_dir.AssignEntry(op.dest_name, std::move(new_entry));
691 return Status::OK();
692 });
693}
694
695Status MockFileSystem::CopyFile(const std::string& src, const std::string& dest) {
696 return BinaryOp::Run(impl_.get(), src, dest, [&](const BinaryOp& op) -> Status {

Callers

nothing calls this directly

Calls 13

RunFunction · 0.85
IOErrorFunction · 0.85
is_dirMethod · 0.80
is_fileMethod · 0.80
SetNameMethod · 0.80
DeleteEntryMethod · 0.80
AssignEntryMethod · 0.80
PathNotFoundFunction · 0.70
OKFunction · 0.50
getMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected