diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-09-25 17:22:05 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-25 17:22:05 +0800 |
| commit | 3497a285c430d0390bfa074c6f9dab5c732b59a1 (patch) | |
| tree | 243626035d251cf5d19deee9845ebe6af2a6582a /crates/vcs/src/data/user.rs | |
| parent | 647cc441eece20218d7387f37d94042e88042057 (diff) | |
| parent | 06b2e2b384da34e30688d1a217859c5cf68ca3bd (diff) | |
Merge pull request #6 from JustEnoughVCS/jvcs_dev
Jvcs dev
Diffstat (limited to 'crates/vcs/src/data/user.rs')
| -rw-r--r-- | crates/vcs/src/data/user.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/vcs/src/data/user.rs b/crates/vcs/src/data/user.rs new file mode 100644 index 0000000..0abd098 --- /dev/null +++ b/crates/vcs/src/data/user.rs @@ -0,0 +1,28 @@ +use crate::current::current_doc_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_doc_dir() -> Option<Self> { + Some(UserDirectory { + local_path: current_doc_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 + } + } +} |
