cap_primitives/fs/via_parent/remove_file.rs
1use super::open_parent;
2use crate::fs::{remove_file_unchecked, MaybeOwnedFile};
3use std::path::Path;
4use std::{fs, io};
5
6/// Implement `remove_file` by `open`ing up the parent component of the path
7/// and then calling `remove_file_unchecked` on the last component.
8pub(crate) fn remove_file(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_file_unchecked(&dir, basename.as_ref())
14}