get nextsync_root

This commit is contained in:
grimhilt committed 2023-06-01 23:58:10 +02:00
1 parent 14183da3ae
commit 04bef223a3
2 files changed
+20

No files matched your search

+1
View File
@@ -0,0 +1 @@
pub mod path;
+19
View 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
}