get nextsync_root

This commit is contained in:
grimhilt 2023-06-01 23:58:10 +02:00
parent 14183da3ae
commit 04bef223a3
2 changed files with 20 additions and 0 deletions

1
src/utils.rs Normal file
View File

@ -0,0 +1 @@
pub mod path;

19
src/utils/path.rs Normal file
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
}