file_operation/file/delete/
sync.rs

1use std::{io::Error, path::Path};
2
3/// Deletes a file at the given path.
4///
5/// - `path`: The file path to delete.
6///
7/// - Returns: `Ok(())` if the file was deleted successfully, or an `Err` with the error details.
8pub fn delete_file(path: &str) -> Result<(), Error> {
9    std::fs::remove_file(path)
10}
11
12/// Deletes a directory and all its contents.
13///
14/// - `path`: The directory path to delete.
15///
16/// - Returns: `Ok(())` if the directory and its contents were deleted successfully, or an `Err` with the error details.
17pub fn delete_dir(path: &str) -> Result<(), Error> {
18    let dir_path: &Path = Path::new(path);
19    std::fs::remove_dir_all(dir_path)?;
20    Ok(())
21}