From 175bb2ce0ce9f81851fe5a82538fe019ae52fa40 Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Fri, 12 Apr 2024 09:55:31 +0100 Subject: [PATCH] feat: improve preservation handling --- src/main.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 47fd996..840cb06 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,9 +61,19 @@ fn vaporise() -> Result<()> { 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() { - if !args.no_preserve && (target == "/" || target == "~") { - println!("{} you're trying to delete an important directory ({})! specify '{}' if you really want to do this", "error:".red().bold(), "--no-preserve".yellow(), target); + if !args.no_preserve && target == root { + 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); }