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

Method DeleteDir

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

Source from the content-addressed store, hash-verified

477}
478
479Status MockFileSystem::DeleteDir(const std::string& path) {
480 RETURN_NOT_OK(ValidatePath(path));
481 auto parts = SplitAbstractPath(path);
482 RETURN_NOT_OK(ValidateAbstractPathParts(parts));
483
484 auto guard = impl_->lock_guard();
485
486 Entry* parent = impl_->FindParent(parts);
487 if (parent == nullptr || !parent->is_dir()) {
488 return PathNotFound(path);
489 }
490 Directory& parent_dir = parent->as_dir();
491 auto child = parent_dir.Find(parts.back());
492 if (child == nullptr) {
493 return PathNotFound(path);
494 }
495 if (!child->is_dir()) {
496 return NotADir(path);
497 }
498
499 bool deleted = parent_dir.DeleteEntry(parts.back());
500 DCHECK(deleted);
501 return Status::OK();
502}
503
504Status MockFileSystem::DeleteDirContents(const std::string& path, bool missing_dir_ok) {
505 RETURN_NOT_OK(ValidatePath(path));

Callers

nothing calls this directly

Calls 12

SplitAbstractPathFunction · 0.85
lock_guardMethod · 0.80
FindParentMethod · 0.80
is_dirMethod · 0.80
backMethod · 0.80
DeleteEntryMethod · 0.80
ValidatePathFunction · 0.70
PathNotFoundFunction · 0.70
NotADirFunction · 0.70
OKFunction · 0.50
FindMethod · 0.45

Tested by

no test coverage detected