cap_primitives/fs/via_parent/
remove_dir.rs

1use super::open_parent;
2use crate::fs::{remove_dir_unchecked, MaybeOwnedFile};
3use std::path::Path;
4use std::{fs, io};
5
6/// Implement `remove_dir` by `open`ing up the parent component of the path and
7/// then calling `remove_dir_unchecked` on the last component.
8pub(crate) fn remove_dir(start: &fs::File, path: &Path) -> io::Result<()> {
9    let start = MaybeOwnedFile::borrowed(start);
10
11    let (dir, basename) = open_parent(start, path)?;
12
13    remove_dir_unchecked(&dir, basename.as_ref())
14}