summaryrefslogtreecommitdiff
path: root/legacy_data/src/data/user.rs
diff options
context:
space:
mode:
Diffstat (limited to 'legacy_data/src/data/user.rs')
-rw-r--r--legacy_data/src/data/user.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/legacy_data/src/data/user.rs b/legacy_data/src/data/user.rs
new file mode 100644
index 0000000..a2326fa
--- /dev/null
+++ b/legacy_data/src/data/user.rs
@@ -0,0 +1,28 @@
+use crate::env::current_cfg_dir;
+use std::path::PathBuf;
+
+pub mod accounts;
+
+pub struct UserDirectory {
+ local_path: PathBuf,
+}
+
+impl UserDirectory {
+ /// Create a user ditectory struct from the current system's document directory
+ pub fn current_cfg_dir() -> Option<Self> {
+ Some(UserDirectory {
+ local_path: current_cfg_dir()?,
+ })
+ }
+
+ /// Create a user directory struct from a specified directory path
+ /// Returns None if the directory does not exist
+ pub fn from_path<P: Into<PathBuf>>(path: P) -> Option<Self> {
+ let local_path = path.into();
+ if local_path.exists() {
+ Some(UserDirectory { local_path })
+ } else {
+ None
+ }
+ }
+}