/// return a bline if the direntry directly matches the options and there's no error
return a bline if the direntry directly matches the options and there's no error
return a bline if the direntry directly matches the options and there ' s no error
fn make_line(
        &mut self,
        parent_id: BId,
        e: fs::DirEntry,
        depth: u16,
    ) -> BLineResult {
        let name = e.file_name();
        let name = match name.to_str() {
            Some(name) => name,
            None => {
                return BLineResult::Invalid;
            }
        };
        if !self.options.show_hidden && name.starts_with('.') {
            return BLineResult::FilteredOutAsHidden;
        }
        let mut has_match = true;
        let mut score = 10000 - i32::from(depth); // we dope less deep entries
        if self.options.pattern.is_some() {
            if let Some(m) = self.options.pattern.find(&name) {
                score += m.score;
            } else {
                has_match = false;
            }
        }
        let file_type = match e.file_type() {
            Ok(ft) => ft,
            Err(_) => {
                return BLineResult::Invalid;
            }
        };
        if file_type.is_file() || file_type.is_symlink() {
            if !has_match {
                return BLineResult::FilteredOutByPattern;
            }
            if self.options.only_folders {
                return BLineResult::FilteredOutAsNonFolder;
            }
        }
        let path = e.path();
        let mut ignore_filter = None;
        if let Some(gif) = &self.blines[parent_id].ignore_filter {
            if !gif.accepts(&path, &name, file_type.is_dir()) {
                return BLineResult::GitIgnored;
            }
            if file_type.is_dir() {
                ignore_filter = Some(gif.extended_to(&path));
            }
        }
        BLineResult::Some(self.blines.alloc(BLine {
            parent_id: Some(parent_id),
            path,
            depth,
            name: name.to_string(),
            file_type,
            children: None,
            next_child_idx: 0,
            has_error: false,
            has_match,
            score,
            ignore_filter,
            nb_kept_children: 0,
        }))
    }
fn make_line ( & mut self , parent_id : BId , e : fs :: DirEntry , depth : u16 , ) -> BLineResult { let name = e . file_name ( ) ; let name = match name . to_str ( ) { Some ( name ) => name , None => { return BLineResult :: Invalid ; } } ; if ! self . options . show_hidden && name . starts_with ( '.' ) { return BLineResult :: FilteredOutAsHidden ; } let mut has_match = true ; let mut score = 10000 - i32 :: from ( depth ) ; // we dope less deep entries if self . options . pattern . is_some ( ) { if let Some ( m ) = self . options . pattern . find ( & name ) { score += m . score ; } else { has_match = false ; } } let file_type = match e . file_type ( ) { Ok ( ft ) => ft , Err ( _ ) => { return BLineResult :: Invalid ; } } ; if file_type . is_file ( ) || file_type . is_symlink ( ) { if ! has_match { return BLineResult :: FilteredOutByPattern ; } if self . options . only_folders { return BLineResult :: FilteredOutAsNonFolder ; } } let path = e . path ( ) ; let mut ignore_filter = None ; if let Some ( gif ) = & self . blines [ parent_id ] . ignore_filter { if ! gif . accepts ( & path , & name , file_type . is_dir ( ) ) { return BLineResult :: GitIgnored ; } if file_type . is_dir ( ) { ignore_filter = Some ( gif . extended_to ( & path ) ) ; } } BLineResult :: Some ( self . blines . alloc ( BLine { parent_id : Some ( parent_id ) , path , depth , name : name . to_string ( ) , file_type , children : None , next_child_idx : 0 , has_error : false , has_match , score , ignore_filter , nb_kept_children : 0 , } ) ) }
return a bline if the direntry directly matches the options and there's no error
return a bline if the direntry directly matches the options and there ' s no error
&mut self
parent_id
BId
e
fs::DirEntry
depth
u16