1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
pub mod command;
pub mod errors;
pub mod data;
pub mod extract;
pub mod version;
pub mod utils {
pub fn ensure_dir() -> std::io::Result<()> {
let home_dir = chiral_common::fs::default_dir();
if !home_dir.exists() {
std::fs::create_dir(home_dir)?;
}
let reports_dir = get_reports_dir();
if !reports_dir.exists() {
std::fs::create_dir(reports_dir)?;
}
Ok(())
}
pub fn get_filepath(filename: &str) -> std::path::PathBuf {
chiral_common::fs::default_dir().join(filename)
}
pub fn get_history_filepath() -> std::path::PathBuf {
chiral_common::fs::default_dir().join("history.txt")
}
pub fn get_reports_dir() -> std::path::PathBuf {
chiral_common::fs::default_dir().join("reports")
}
pub fn get_report_files() -> std::fs::ReadDir {
std::fs::read_dir(get_reports_dir()).unwrap()
}
pub fn get_report_filepath(job_id: &str) -> std::path::PathBuf {
let filename = format!("{job_id}.txt");
get_reports_dir().join(filename)
}
pub fn get_report_filepath_with_timestamp(job_id: &str) -> std::path::PathBuf {
let time_str = chrono::Utc::now().to_string();
let filename = format!("{job_id} {time_str}.txt");
get_reports_dir().join(filename)
}
pub fn get_jobs_filepath() -> std::path::PathBuf {
chiral_common::fs::default_dir().join("jobs.txt")
}
}