Allow getting CSL dir outside csl mod

This commit is contained in:
Jake Howard 2017-09-10 12:55:21 +01:00
parent fa9673b397
commit bf09d2c6c8
Signed by: jake
GPG key ID: 57AFB45680EDD477
3 changed files with 9 additions and 3 deletions

View file

@ -4,6 +4,11 @@ use std::path::PathBuf;
use utils::get_exe_dir;
use std::fs::File;
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 {
@ -12,7 +17,7 @@ fn get_temp_file() -> PathBuf {
pub fn unpack_csl(csl_name: String) -> PathBuf {
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");
debug_assert!(archive.len() >= 10);
let mut csl_zip_file = archive.by_name(&format!("{}.csl", csl_name)).expect(&format!(

View file

@ -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";

View file

@ -10,7 +10,7 @@ use utils::result_override;
fn get_config_path() -> PathBuf {
let mut working_dir = current_dir().unwrap();
working_dir.push(consts::CONFIG_FILE);
working_dir.push(consts::CONFIG_FILE_NAME);
return working_dir;
}