use std::path::PathBuf;
use super::ParseError;
pub fn get_root_and_name(path: PathBuf) -> Result<(PathBuf, String), ParseError> {
let name = path.file_name().unwrap();
let name = name.to_str().unwrap();
let name = &name[..name.len() - ".pink".len()];
let mut root = path.clone();
root.pop();
Ok((root, name.to_string()))
}
pub fn file_resolver(root: PathBuf) -> impl Fn(&str) -> Option<String> {
move |name: &str| {
let mut path = root.clone();
path.push(name);
path.set_extension("pink");
std::fs::read_to_string(path).ok()
}
}