use std::path::Path;
use bstr::ByteSlice;
use crate::stack::Platform;
impl<'a> Platform<'a> {
pub fn path(&self) -> &'a Path {
self.parent.stack.current()
}
pub fn is_excluded(&self) -> bool {
self.matching_exclude_pattern()
.map_or(false, |m| !m.pattern.is_negative())
}
pub fn matching_exclude_pattern(&self) -> Option<gix_ignore::search::Match<'_>> {
let ignore = self.parent.state.ignore_or_panic();
let relative_path =
gix_path::to_unix_separators_on_windows(gix_path::into_bstr(self.parent.stack.current_relative()));
ignore.matching_exclude_pattern(relative_path.as_bstr(), self.is_dir, self.parent.case)
}
#[cfg(feature = "attributes")]
pub fn matching_attributes(&self, out: &mut gix_attributes::search::Outcome) -> bool {
let attrs = self.parent.state.attributes_or_panic();
let relative_path =
gix_path::to_unix_separators_on_windows(gix_path::into_bstr(self.parent.stack.current_relative()));
attrs.matching_attributes(relative_path.as_bstr(), self.parent.case, self.is_dir, out)
}
}
impl<'a> std::fmt::Debug for Platform<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Debug::fmt(&self.path(), f)
}
}