#[cfg(target_family = "windows")]
use remove_dir_all::remove_dir_all;
#[cfg(not(target_family = "windows"))]
use std::fs::remove_dir_all;
use std::io::Result;
use std::path::Path;
pub enum Clean {
Cleaned,
NotCleaned,
}
pub trait DoCleanUp {
fn do_cleanup(&self, path_to_remove: &Path) -> Result<Clean>;
}
#[derive(Default)]
pub struct ProperCleaner;
impl DoCleanUp for ProperCleaner {
fn do_cleanup(&self, path_to_remove: &Path) -> Result<Clean> {
remove_dir_all(path_to_remove).map(|_| Clean::Cleaned)
}
}
#[derive(Default)]
pub struct DryRunCleaner;
impl DoCleanUp for DryRunCleaner {
fn do_cleanup(&self, _: &Path) -> Result<Clean> {
Ok(Clean::NotCleaned)
}
}