Skip to main content

find_files

Function find_files 

Source
pub fn find_files(path: &Path, ctx: &Arc<SearchCtx>, tx: &Sender<String>)
Expand description

Find files within the specified path that match the pattern in the context

It just looks at the filename, it doesn’t check for file permissions, types or anything

§Arguments

  • path - Path to search
  • ctx - Search context
  • tx - Channel to send found paths

§Examples

use rayon::iter::{ParallelBridge, ParallelIterator};
use std::{
    env::{split_paths, var_os},
    path::PathBuf,
    sync::Arc,
};
use superwhich::{SearchCtx, colored::Color, crossbeam::channel::unbounded, find_files};

let ctx = Arc::new(
    SearchCtx::new("GURE".to_string())
        .threshold(0.7)
        .color(Color::Red),
);
let (tx, rx) = unbounded();

split_paths(&var_os("PATH").expect("PATH is not set"))
    .par_bridge()
    .for_each(|path: PathBuf| {
        find_files(&path, &ctx, &tx);
    });

while let Ok(path) = rx.try_recv() {
    println!("{}", path);
}