1 2 3 4 5 6 7 8 9 10 11 12 13 14
use std::{ fs::{remove_dir_all, remove_file, Metadata}, error::Error }; pub fn remove_all_file( path: &String, stat: &Metadata ) -> Result<(), Box<dyn Error>> { if stat.is_dir() { remove_dir_all(path)?; } else { remove_file(path)?; } Ok(()) }