aboutsummaryrefslogtreecommitdiff
path: root/src/utils.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-07-10 18:05:30 +0100
committerAkshay <[email protected]>2020-07-10 18:05:30 +0100
commitb6ea375485083860094a904b7a6c7d97fa42b8f8 (patch)
tree52dba4e164e23b2fba4a8764c145d6d734ed7fab /src/utils.rs
parent872297132d9d1fa39545fee54a1a25a95bdbe22d (diff)
follow XDG_DATA_DIR spec for app data
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs
index 55900b0..ab7e7ef 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -1,4 +1,6 @@
1use cursive::theme::{BaseColor, Color}; 1use cursive::theme::{BaseColor, Color};
2use directories::ProjectDirs;
3use std::path::{Path, PathBuf};
2 4
3pub struct AppConfig { 5pub struct AppConfig {
4 pub true_chr: char, 6 pub true_chr: char,
@@ -30,3 +32,13 @@ pub fn load_configuration_file() -> AppConfig {
30 future_color: Color::Light(BaseColor::Black), 32 future_color: Color::Light(BaseColor::Black),
31 }; 33 };
32} 34}
35
36pub fn data_file() -> PathBuf {
37 if let Some(proj_dirs) = ProjectDirs::from("rs", "nerdypepper", "dijo") {
38 let mut data_file = PathBuf::from(proj_dirs.data_dir());
39 data_file.push("habit_record.json");
40 return data_file;
41 } else {
42 panic!("Invalid home directory!")
43 };
44}