pub struct VTCodeGitignore { /* private fields */ }Expand description
Represents a .vtcodegitignore file with pattern matching capabilities
Implementations§
Source§impl VTCodeGitignore
impl VTCodeGitignore
Sourcepub async fn new() -> Result<Self>
pub async fn new() -> Result<Self>
Create a new VTCodeGitignore instance by looking for .vtcodegitignore in the current directory
Sourcepub async fn from_directory(root_dir: &Path) -> Result<Self>
pub async fn from_directory(root_dir: &Path) -> Result<Self>
Create a VTCodeGitignore instance from a specific directory
Sourcepub fn should_exclude(&self, file_path: &Path) -> bool
pub fn should_exclude(&self, file_path: &Path) -> bool
Check if a file path should be excluded based on the .vtcodegitignore patterns
Sourcepub fn should_exclude_with_file_type(
&self,
file_path: &Path,
file_type: Option<FileType>,
) -> bool
pub fn should_exclude_with_file_type( &self, file_path: &Path, file_type: Option<FileType>, ) -> bool
Same as Self::should_exclude using a file type the caller already has.
Traversal code holds each entry’s FileType from readdir, so calling
is_dir() again costs one stat per entry for a fact already in hand.
A symlink’s own type says nothing about its target, and this matcher has
always followed the link (Path::is_dir), so symlinks and unknown types
take the stat path rather than guessing.
Sourcepub fn should_exclude_with_is_dir(&self, file_path: &Path, is_dir: bool) -> bool
pub fn should_exclude_with_is_dir(&self, file_path: &Path, is_dir: bool) -> bool
Same as Self::should_exclude with a caller-supplied directory flag.
The caller must have resolved the flag from the target, not from a
symlink’s own type; prefer Self::should_exclude_with_file_type,
which applies that rule.
Sourcepub fn filter_paths(&self, paths: Vec<PathBuf>) -> Vec<PathBuf>
pub fn filter_paths(&self, paths: Vec<PathBuf>) -> Vec<PathBuf>
Filter a list of file paths based on .vtcodegitignore patterns
Sourcepub fn pattern_count(&self) -> usize
pub fn pattern_count(&self) -> usize
Get the number of patterns loaded