added error output feature when output file path already exist #303

This commit is contained in:
DustInDark
2021-12-20 01:44:15 +09:00
parent 11dcc252ca
commit 422c0eacdf

View File

@@ -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") {