scan_files

Function scan_files 

Source
pub fn scan_files(config: &ScanConfig) -> Result<Vec<PathBuf>>
Expand description

Scans the directory specified in the configuration and returns a list of files to include.

This function utilizes the ignore crate to respect .gitignore rules. It also performs additional filtering to exclude common build artifacts (such as node_modules, target, .git, etc.) regardless of gitignore settings.

§Arguments

  • config - The configuration object containing the root path.

§Returns

  • Result<Vec<PathBuf>> - A vector containing absolute paths to the valid files found.

§Example

use srcpack::{ScanConfig, scan_files};

let config = ScanConfig::new(".", vec![String::from("*.mp4"), String::from("!special-include.mp4")]);
match scan_files(&config) {
    Ok(files) => println!("Found {} files respecting .gitignore", files.len()),
    Err(e) => eprintln!("Error scanning directory: {}", e),
}