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

Method DeleteFile

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

Source from the content-addressed store, hash-verified

535}
536
537Status MockFileSystem::DeleteFile(const std::string& path) {
538 RETURN_NOT_OK(ValidatePath(path));
539 auto parts = SplitAbstractPath(path);
540 RETURN_NOT_OK(ValidateAbstractPathParts(parts));
541
542 auto guard = impl_->lock_guard();
543
544 Entry* parent = impl_->FindParent(parts);
545 if (parent == nullptr || !parent->is_dir()) {
546 return PathNotFound(path);
547 }
548 Directory& parent_dir = parent->as_dir();
549 auto child = parent_dir.Find(parts.back());
550 if (child == nullptr) {
551 return PathNotFound(path);
552 }
553 if (!child->is_file()) {
554 return NotAFile(path);
555 }
556 bool deleted = parent_dir.DeleteEntry(parts.back());
557 DCHECK(deleted);
558 return Status::OK();
559}
560
561Result<FileInfo> MockFileSystem::GetFileInfo(const std::string& path) {
562 RETURN_NOT_OK(ValidatePath(path));

Callers

nothing calls this directly

Calls 13

SplitAbstractPathFunction · 0.85
lock_guardMethod · 0.80
FindParentMethod · 0.80
is_dirMethod · 0.80
backMethod · 0.80
is_fileMethod · 0.80
DeleteEntryMethod · 0.80
ValidatePathFunction · 0.70
PathNotFoundFunction · 0.70
NotAFileFunction · 0.70
OKFunction · 0.50

Tested by

no test coverage detected