summaryrefslogtreecommitdiff
path: root/crates/vcs_data/src/data/user.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-10-06 04:13:32 +0800
committerGitHub <noreply@github.com>2025-10-06 04:13:32 +0800
commit4a32781c096f30cb39e16c745076e6b7537929cd (patch)
tree304075598071f55cb9dc15dc7ac8d9b8740e511e /crates/vcs_data/src/data/user.rs
parent57959d26c68dc1d403f527f1f8b407abe8059a28 (diff)
parent85f7c35d6c573b715c166fe7501225ecab6731ea (diff)
Merge pull request #17 from JustEnoughVCS/jvcs_dev
Jvcs dev
Diffstat (limited to 'crates/vcs_data/src/data/user.rs')
-rw-r--r--crates/vcs_data/src/data/user.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/vcs_data/src/data/user.rs b/crates/vcs_data/src/data/user.rs
new file mode 100644
index 0000000..0abd098
--- /dev/null
+++ b/crates/vcs_data/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
+ }
+ }
+}