use std::{borrow::Cow, ffi::OsString, path::Path};
use crate::Source;
impl Source {
pub fn storage_location(self, env_var: &mut dyn FnMut(&str) -> Option<OsString>) -> Option<Cow<'static, Path>> {
use Source::*;
Some(match self {
GitInstallation => gix_path::env::installation_config_prefix()?
.join("gitattributes")
.into(),
System => {
if env_var("GIT_ATTR_NOSYSTEM").is_some() {
return None;
} else {
gix_path::env::system_prefix()?.join("etc/gitattributes").into()
}
}
Git => return gix_path::env::xdg_config("attributes", env_var).map(Cow::Owned),
Local => Cow::Borrowed(Path::new("info/attributes")),
})
}
}