fn list_files(&self, regex: &str) -> AppResult<Vec<PathBuf>> {
        // create compiled regex
        let re = regex::Regex::new(regex).map_err(|e| context!(e, "error in regex {}", regex))?;

        // get entries
        let entries = read_dir(self)
            .map_err(|e| context!(e, "error trying to read files from {:?} ", self))?;

        // get the list of corresponding files to the regex
        let files: Vec<PathBuf> = entries
            .filter_map(Result::ok) // filter only those result = Ok()
            .filter(|e| e.path().is_match(&re)) // filter only having a path matching the regex
            .map(|e| e.path()) // extract the path from the entry
            .collect();

        Ok(files)
    }
// Gives the list of files from a directory, matching the given regex.
Gives the list of files from a directory, matching the given regex.
Gives the list of files from a directory matching the given regex .
fn list_files(&self, regex: &str) -> AppResult<Vec<PathBuf>> {
        // create compiled regex
        let re = regex::Regex::new(regex).map_err(|e| context!(e, "error in regex {}", regex))?;
        // get entries
        let entries = read_dir(self)
            .map_err(|e| context!(e, "error trying to read files from {:?} ", self))?;
        // get the list of corresponding files to the regex
        let files: Vec<PathBuf> = entries
            .filter_map(Result::ok) // filter only those result = Ok()
            .filter(|e| e.path().is_match(&re)) // filter only having a path matching the regex
            .map(|e| e.path()) // extract the path from the entry
            .collect();
        Ok(files)
    }
fn list_files ( & self , regex : & str ) -> AppResult < Vec < PathBuf > > { // create compiled regex let re = regex :: Regex :: new ( regex ) . map_err ( | e | context ! ( e " " regex ) ) ? ; // get entries let entries = read_dir ( self ) . map_err ( | e | context ! ( e " " self ) ) ? ; // get the list of corresponding files to the regex let files : Vec < PathBuf > = entries . filter_map ( Result :: ok ) // filter only those result = Ok() . filter ( | e | e . path ( ) . is_match ( & re ) ) // filter only having a path matching the regex . map ( | e | e . path ( ) ) // extract the path from the entry . collect ( ) ; Ok ( files ) }
Gives the list of files from a directory, matching the given regex.
Gives the list of files from a directory matching the given regex .
&self
regex
&str
&self
regex
&str