From 9290eed6564d05d377cbd497d90c481b32253237 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 13 Sep 2017 13:37:35 +0100 Subject: [PATCH] Move temp file to utils --- src/config/csl.rs | 8 +------- src/utils.rs | 6 ++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/config/csl.rs b/src/config/csl.rs index 97a4eab..49221ec 100644 --- a/src/config/csl.rs +++ b/src/config/csl.rs @@ -1,7 +1,6 @@ use zip::ZipArchive; -use mktemp::Temp; use std::path::PathBuf; -use utils::{get_exe_dir, result_override}; +use utils::{get_exe_dir, result_override, get_temp_file}; use std::fs::File; use std::io::{Read, Write}; use config::consts::CSL_FILE_NAME; @@ -11,11 +10,6 @@ fn get_csl_path() -> PathBuf { } -fn get_temp_file() -> PathBuf { - return Temp::new_file().expect("Failed to create temporary file").to_path_buf(); -} - - fn get_csl_data(csl_name: String) -> Result { let zip_file = try!(result_override(File::open(get_csl_path()), "Failed to read CSL zip".into())); diff --git a/src/utils.rs b/src/utils.rs index 8ce95e6..6e8f043 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -3,6 +3,8 @@ use std::process::exit; use std::io::{self, Write}; use std::env::{current_exe, current_dir}; use std::path::PathBuf; +use mktemp::Temp; + #[inline] @@ -45,3 +47,7 @@ pub fn resolve_path(path: String) -> PathBuf { let base_dir = current_dir().unwrap(); return base_dir.join(path); } + +pub fn get_temp_file() -> PathBuf { + return Temp::new_file().expect("Failed to create temporary file").to_path_buf(); +}