pub fn is_path_suitable<P: AsRef<Path>>(path: P, max_size: usize) -> bool
Expand description

return true when the file looks suitable for searching as text.

This function is quite slow as it creates a memmap just to check a few bytes. If the memmap can be used, prefer get_mmap_if_not_binary

Examples found in repository?
src/pattern/content_regex_pattern.rs (line 59)
58
59
60
61
62
63
64
65
66
67
68
69
70
    pub fn score_of(&self, candidate: Candidate) -> Option<i32> {
        if !candidate.regular_file || !is_path_suitable(candidate.path, self.max_file_size) {
            return None;
        }
        match self.has_match(candidate.path) {
            Ok(true) => Some(1),
            Ok(false) => None,
            Err(e) => {
                debug!("error while scanning {:?} : {:?}", candidate.path, e);
                None
            }
        }
    }