add: used check path func base on execution path #618
This commit is contained in:
@@ -241,16 +241,20 @@ impl ConfigReader<'_> {
|
|||||||
args: parse,
|
args: parse,
|
||||||
headless_help: String::default(),
|
headless_help: String::default(),
|
||||||
event_timeline_config: load_eventcode_info(
|
event_timeline_config: load_eventcode_info(
|
||||||
CURRENT_EXE_PATH
|
utils::check_setting_path(
|
||||||
.join("rules/config/statistics_event_info.txt")
|
&CURRENT_EXE_PATH.to_path_buf(),
|
||||||
.to_str()
|
"rules/config/statistics_event_info.txt",
|
||||||
.unwrap(),
|
)
|
||||||
|
.to_str()
|
||||||
|
.unwrap(),
|
||||||
),
|
),
|
||||||
target_eventids: load_target_ids(
|
target_eventids: load_target_ids(
|
||||||
CURRENT_EXE_PATH
|
utils::check_setting_path(
|
||||||
.join("rules/config/target_event_IDs.txt")
|
&CURRENT_EXE_PATH.to_path_buf(),
|
||||||
.to_str()
|
"rules/config/target_event_IDs.txt",
|
||||||
.unwrap(),
|
)
|
||||||
|
.to_str()
|
||||||
|
.unwrap(),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,18 +54,19 @@ lazy_static! {
|
|||||||
pub static ref STATISTICS_FLAG: bool = configs::CONFIG.read().unwrap().args.statistics;
|
pub static ref STATISTICS_FLAG: bool = configs::CONFIG.read().unwrap().args.statistics;
|
||||||
pub static ref LOGONSUMMARY_FLAG: bool = configs::CONFIG.read().unwrap().args.logon_summary;
|
pub static ref LOGONSUMMARY_FLAG: bool = configs::CONFIG.read().unwrap().args.logon_summary;
|
||||||
pub static ref TAGS_CONFIG: HashMap<String, String> = Message::create_output_filter_config(
|
pub static ref TAGS_CONFIG: HashMap<String, String> = Message::create_output_filter_config(
|
||||||
CURRENT_EXE_PATH
|
utils::check_setting_path(&CURRENT_EXE_PATH.to_path_buf(), "config/output_tag.txt")
|
||||||
.join("config/output_tag.txt")
|
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
true,
|
true,
|
||||||
configs::CONFIG.read().unwrap().args.all_tags
|
configs::CONFIG.read().unwrap().args.all_tags
|
||||||
);
|
);
|
||||||
pub static ref CH_CONFIG: HashMap<String, String> = Message::create_output_filter_config(
|
pub static ref CH_CONFIG: HashMap<String, String> = Message::create_output_filter_config(
|
||||||
CURRENT_EXE_PATH
|
utils::check_setting_path(
|
||||||
.join("rules/config/channel_abbreviations.txt")
|
&CURRENT_EXE_PATH.to_path_buf(),
|
||||||
.to_str()
|
"rules/config/channel_abbreviations.txt"
|
||||||
.unwrap(),
|
)
|
||||||
|
.to_str()
|
||||||
|
.unwrap(),
|
||||||
false,
|
false,
|
||||||
configs::CONFIG.read().unwrap().args.all_tags
|
configs::CONFIG.read().unwrap().args.all_tags
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -71,8 +71,7 @@ pub fn value_to_string(value: &Value) -> Option<String> {
|
|||||||
|
|
||||||
pub fn read_txt(filename: &str) -> Result<Vec<String>, String> {
|
pub fn read_txt(filename: &str) -> Result<Vec<String>, String> {
|
||||||
let filepath = if filename.starts_with("./") {
|
let filepath = if filename.starts_with("./") {
|
||||||
CURRENT_EXE_PATH
|
check_setting_path(&CURRENT_EXE_PATH.to_path_buf(), filename)
|
||||||
.join(filename)
|
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string()
|
.to_string()
|
||||||
|
|||||||
27
src/main.rs
27
src/main.rs
@@ -144,30 +144,15 @@ impl App {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// カレントディレクトリ以外からの実行の際にrules-configオプションの指定がないとエラーが発生することを防ぐための処理
|
// カレントディレクトリ以外からの実行の際にrules-configオプションの指定がないとエラーが発生することを防ぐための処理
|
||||||
if configs::CONFIG
|
if configs::CONFIG.read().unwrap().args.config == Path::new("./rules/config") {
|
||||||
.read()
|
configs::CONFIG.write().unwrap().args.config =
|
||||||
.unwrap()
|
utils::check_setting_path(&CURRENT_EXE_PATH.to_path_buf(), "./rules/config");
|
||||||
.args
|
|
||||||
.config
|
|
||||||
.to_str()
|
|
||||||
.unwrap()
|
|
||||||
== "./rules/config"
|
|
||||||
{
|
|
||||||
configs::CONFIG.write().unwrap().args.config = CURRENT_EXE_PATH.join("rules/config");
|
|
||||||
// hayabusa.exeが存在するパスにrules/configがない場合はカレントディレクトリのrules/configを確認する
|
|
||||||
if !configs::CONFIG.read().unwrap().args.config.exists() {
|
|
||||||
configs::CONFIG.write().unwrap().args.config =
|
|
||||||
Path::new("./rules/config").to_path_buf();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// カレントディレクトリ以外からの実行の際にrulesオプションの指定がないとエラーが発生することを防ぐための処理
|
// カレントディレクトリ以外からの実行の際にrulesオプションの指定がないとエラーが発生することを防ぐための処理
|
||||||
if configs::CONFIG.read().unwrap().args.rules.to_str().unwrap() == "./rules" {
|
if configs::CONFIG.read().unwrap().args.rules == Path::new("./rules") {
|
||||||
configs::CONFIG.write().unwrap().args.rules = CURRENT_EXE_PATH.join("rules");
|
configs::CONFIG.write().unwrap().args.rules =
|
||||||
// hayabusa.exeが存在するパスにrulesがない場合はカレントディレクトリのrulesを確認する
|
utils::check_setting_path(&CURRENT_EXE_PATH.to_path_buf(), "./rules");
|
||||||
if !configs::CONFIG.read().unwrap().args.rules.exists() {
|
|
||||||
configs::CONFIG.write().unwrap().args.rules = Path::new("./rules").to_path_buf();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(csv_path) = &configs::CONFIG.read().unwrap().args.output {
|
if let Some(csv_path) = &configs::CONFIG.read().unwrap().args.output {
|
||||||
|
|||||||
Reference in New Issue
Block a user