feat: improve preservation handling

This commit is contained in:
Muhammad Nauman Raza 2024-04-12 09:55:31 +01:00
parent 2d70fd48d7
commit 175bb2ce0c

View file

@ -61,9 +61,19 @@ fn vaporise() -> Result<()> {
confirm_once(); confirm_once();
} }
let root: &str;
if cfg!(windows) {
root = "C:\\";
} else if cfg!(unix) {
root = "/";
} else {
root = "N/A";
}
for target in args.targets.iter() { for target in args.targets.iter() {
if !args.no_preserve && (target == "/" || target == "~") { if !args.no_preserve && target == root {
println!("{} you're trying to delete an important directory ({})! specify '{}' if you really want to do this", "error:".red().bold(), "--no-preserve".yellow(), target); println!("{} you're trying to delete the root directory ({})! specify '{}' if you really want to do this", "error:".red().bold(), "--no-preserve".yellow(), target);
process::exit(0); process::exit(0);
} }