blob: 0abd098e9c98fdac26c3e8b1422448f363fb0589 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
}
}
}
|