Allow getting CSL dir outside csl mod
This commit is contained in:
parent
fa9673b397
commit
bf09d2c6c8
3 changed files with 9 additions and 3 deletions
|
@ -4,6 +4,11 @@ use std::path::PathBuf;
|
||||||
use utils::get_exe_dir;
|
use utils::get_exe_dir;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
use config::consts::CSL_FILE_NAME;
|
||||||
|
|
||||||
|
pub fn get_csl_path() -> PathBuf {
|
||||||
|
return get_exe_dir().join(CSL_FILE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn get_temp_file() -> PathBuf {
|
fn get_temp_file() -> PathBuf {
|
||||||
|
@ -12,7 +17,7 @@ fn get_temp_file() -> PathBuf {
|
||||||
|
|
||||||
pub fn unpack_csl(csl_name: String) -> PathBuf {
|
pub fn unpack_csl(csl_name: String) -> PathBuf {
|
||||||
let file = get_temp_file();
|
let file = get_temp_file();
|
||||||
let zip_file = File::open(get_exe_dir().join("csl.zip")).expect("Failed to read CSL zip");
|
let zip_file = File::open(get_csl_path()).expect("Failed to read CSL zip");
|
||||||
let mut archive = ZipArchive::new(zip_file).expect("Failed to load zip file");
|
let mut archive = ZipArchive::new(zip_file).expect("Failed to load zip file");
|
||||||
debug_assert!(archive.len() >= 10);
|
debug_assert!(archive.len() >= 10);
|
||||||
let mut csl_zip_file = archive.by_name(&format!("{}.csl", csl_name)).expect(&format!(
|
let mut csl_zip_file = archive.by_name(&format!("{}.csl", csl_name)).expect(&format!(
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
pub const CONFIG_FILE: &str = "mdp.yml";
|
pub const CONFIG_FILE_NAME: &str = "mdp.yml";
|
||||||
|
pub const CSL_FILE_NAME: &str = "csl.zip";
|
||||||
|
|
|
@ -10,7 +10,7 @@ use utils::result_override;
|
||||||
|
|
||||||
fn get_config_path() -> PathBuf {
|
fn get_config_path() -> PathBuf {
|
||||||
let mut working_dir = current_dir().unwrap();
|
let mut working_dir = current_dir().unwrap();
|
||||||
working_dir.push(consts::CONFIG_FILE);
|
working_dir.push(consts::CONFIG_FILE_NAME);
|
||||||
return working_dir;
|
return working_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue