fixity 0.0.1

Storage for structured and unstructured data backed by an immutable storage engine
use std::path::{Path, PathBuf};

/// Resolve an existing fixity dir above the current directory.
pub(crate) fn resolve<P>(fixi_dir_name: P, mut root: PathBuf) -> Option<PathBuf>
where
    P: AsRef<Path>,
{
    let fixi_dir = root.join(&fixi_dir_name);
    if fixi_dir.exists() {
        return Some(fixi_dir);
    }
    while root.pop() {
        let fixi_dir = root.join(&fixi_dir_name);
        if fixi_dir.exists() {
            return Some(fixi_dir);
        }
    }
    None
}