From 422c0eacdf970e8c1bce9b20741e6ff48139fc7f Mon Sep 17 00:00:00 2001 From: DustInDark Date: Mon, 20 Dec 2021 01:44:15 +0900 Subject: [PATCH] added error output feature when output file path already exist #303 --- src/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main.rs b/src/main.rs index 3cd5aa26..087ba29c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,6 +19,7 @@ use std::collections::{HashMap, HashSet}; use std::fmt::Display; use std::fs::OpenOptions; use std::io::BufWriter; +use std::path::Path; use std::sync::Arc; use std::{ fs::{self, File}, @@ -69,6 +70,16 @@ impl App { ); return; } + if let Some(csv_path) = configs::CONFIG.read().unwrap().args.value_of("output") { + if Path::new(csv_path).exists() { + AlertMessage::alert( + &mut std::io::stderr().lock(), + " file name in --output already exist other file. Please input unique file path.".to_owned(), + ) + .ok(); + return; + } + } AlertMessage::create_error_log(ERROR_LOG_PATH.to_string()); if let Some(filepath) = configs::CONFIG.read().unwrap().args.value_of("filepath") { if !filepath.ends_with(".evtx") {