diff --git a/src/util_file.rs b/src/util_file.rs index 1b6919b..13e24d2 100644 --- a/src/util_file.rs +++ b/src/util_file.rs @@ -77,6 +77,20 @@ impl Iterator for JoinFilesReader { } } +pub fn find_parents_exists_dir(dir: &str) -> Option { + match PathBuf::from(".").canonicalize() { + Err(_) => None, + Ok(mut path) => loop { + if path.join(dir).is_dir() { + return Some(path); + } + if !path.pop() { + return None; + } + } + } +} + pub fn locate_file(files: &[String]) -> Option { for f in files { match PathBuf::from(&resolve_file_path(f)) {