| 502 | } |
| 503 | |
| 504 | Status MockFileSystem::DeleteDirContents(const std::string& path, bool missing_dir_ok) { |
| 505 | RETURN_NOT_OK(ValidatePath(path)); |
| 506 | auto parts = SplitAbstractPath(path); |
| 507 | RETURN_NOT_OK(ValidateAbstractPathParts(parts)); |
| 508 | |
| 509 | auto guard = impl_->lock_guard(); |
| 510 | |
| 511 | if (parts.empty()) { |
| 512 | // Wipe filesystem |
| 513 | return internal::InvalidDeleteDirContents(path); |
| 514 | } |
| 515 | |
| 516 | Entry* entry = impl_->FindEntry(parts); |
| 517 | if (entry == nullptr) { |
| 518 | if (missing_dir_ok) { |
| 519 | return Status::OK(); |
| 520 | } |
| 521 | return PathNotFound(path); |
| 522 | } |
| 523 | if (!entry->is_dir()) { |
| 524 | return NotADir(path); |
| 525 | } |
| 526 | entry->as_dir().entries.clear(); |
| 527 | return Status::OK(); |
| 528 | } |
| 529 | |
| 530 | Status MockFileSystem::DeleteRootDirContents() { |
| 531 | auto guard = impl_->lock_guard(); |
nothing calls this directly
no test coverage detected