diff options
author | Akshay <[email protected]> | 2020-07-10 18:05:30 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2020-07-10 18:05:30 +0100 |
commit | b6ea375485083860094a904b7a6c7d97fa42b8f8 (patch) | |
tree | 52dba4e164e23b2fba4a8764c145d6d734ed7fab /src/utils.rs | |
parent | 872297132d9d1fa39545fee54a1a25a95bdbe22d (diff) |
follow XDG_DATA_DIR spec for app data
Diffstat (limited to 'src/utils.rs')
-rw-r--r-- | src/utils.rs | 12 |
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 @@ | |||
1 | use cursive::theme::{BaseColor, Color}; | 1 | use cursive::theme::{BaseColor, Color}; |
2 | use directories::ProjectDirs; | ||
3 | use std::path::{Path, PathBuf}; | ||
2 | 4 | ||
3 | pub struct AppConfig { | 5 | pub 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 | |||
36 | pub 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 | } | ||