get nextsync_root
This commit is contained in:
parent
14183da3ae
commit
04bef223a3
1
src/utils.rs
Normal file
1
src/utils.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod path;
|
19
src/utils/path.rs
Normal file
19
src/utils/path.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
use std::env;
|
||||||
|
use std::path::{PathBuf, Path};
|
||||||
|
|
||||||
|
pub fn nextsync_root() -> Option<PathBuf> {
|
||||||
|
let mut path = env::current_dir().unwrap();
|
||||||
|
let root = loop {
|
||||||
|
path.push(".nextsync");
|
||||||
|
if path.exists() {
|
||||||
|
path.pop();
|
||||||
|
break Some(path);
|
||||||
|
}
|
||||||
|
path.pop();
|
||||||
|
path.pop();
|
||||||
|
if path == Path::new("/") {
|
||||||
|
break None;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
root
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user