make it so it looks for config jsons in the executable dir, NOT the working dir
This commit is contained in:
parent
2ee0b85b69
commit
a204a37843
1 changed files with 14 additions and 6 deletions
20
src/main.rs
20
src/main.rs
|
@ -7,9 +7,14 @@ use idmangler_lib::{
|
||||||
StartData, TypeData,
|
StartData, TypeData,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::{
|
||||||
use std::fs;
|
collections::HashMap,
|
||||||
use std::panic;
|
env,
|
||||||
|
fs,
|
||||||
|
panic
|
||||||
|
};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
mod structures;
|
mod structures;
|
||||||
use crate::structures::*;
|
use crate::structures::*;
|
||||||
mod errorfr;
|
mod errorfr;
|
||||||
|
@ -40,13 +45,16 @@ fn cook() -> Result<(), Errorfr> {
|
||||||
// enable fancypanic when building for release
|
// enable fancypanic when building for release
|
||||||
// fancypanic();
|
// fancypanic();
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
let mut executablePath = env::current_exe().unwrap();
|
||||||
|
PathBuf::pop(&mut executablePath);
|
||||||
|
let executablePath = executablePath.to_str().unwrap();
|
||||||
|
|
||||||
let mut debug_mode = false;
|
let mut debug_mode = false;
|
||||||
if args.debug == true {
|
if args.debug == true {
|
||||||
debug_mode = true;
|
debug_mode = true;
|
||||||
println!("Debug mode enabled");
|
println!("Debug mode enabled");
|
||||||
};
|
};
|
||||||
let mut config: String = String::from("config.json");
|
let mut config: String = String::from(executablePath.to_owned()+"config.json");
|
||||||
if let Some(configpathargs) = args.config {
|
if let Some(configpathargs) = args.config {
|
||||||
config = configpathargs;
|
config = configpathargs;
|
||||||
}
|
}
|
||||||
|
@ -55,10 +63,10 @@ fn cook() -> Result<(), Errorfr> {
|
||||||
let json_config: Jsonconfig = serde_json::from_reader(fs::File::open(config)
|
let json_config: Jsonconfig = serde_json::from_reader(fs::File::open(config)
|
||||||
.map_err(|_| Errorfr::ItemJsonMissing)?)
|
.map_err(|_| Errorfr::ItemJsonMissing)?)
|
||||||
.map_err(|e| Errorfr::ItemJsonCorrupt(e))?;
|
.map_err(|e| Errorfr::ItemJsonCorrupt(e))?;
|
||||||
let idsmap: HashMap<String, u8> = serde_json::from_reader(fs::File::open("id_keys.json")
|
let idsmap: HashMap<String, u8> = serde_json::from_reader(fs::File::open(executablePath.to_owned()+"id_keys.json")
|
||||||
.map_err(|_| Errorfr::IDMapJsonMissing)?)
|
.map_err(|_| Errorfr::IDMapJsonMissing)?)
|
||||||
.map_err(|_| Errorfr::IDMapJsonCorrupt)?;
|
.map_err(|_| Errorfr::IDMapJsonCorrupt)?;
|
||||||
let json_shiny: Vec<Shinystruct> = serde_json::from_reader(fs::File::open("shiny_stats.json")
|
let json_shiny: Vec<Shinystruct> = serde_json::from_reader(fs::File::open(executablePath.to_owned()+"shiny_stats.json")
|
||||||
.map_err(|_| Errorfr::ShinyJsonMissing)?)
|
.map_err(|_| Errorfr::ShinyJsonMissing)?)
|
||||||
.map_err(|_| Errorfr::ShinyJsonCorrupt)?;
|
.map_err(|_| Errorfr::ShinyJsonCorrupt)?;
|
||||||
// println!("{:?}",idsmap.get("airDamage"));
|
// println!("{:?}",idsmap.get("airDamage"));
|
||||||
|
|
Loading…
Reference in a new issue