| 477 | } |
| 478 | |
| 479 | Status 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 | |
| 504 | Status MockFileSystem::DeleteDirContents(const std::string& path, bool missing_dir_ok) { |
| 505 | RETURN_NOT_OK(ValidatePath(path)); |
nothing calls this directly
no test coverage detected