filetypes.rs
This file
Path
src/filetypes.rs
52 lines · 1.6 KiB · Rust
Last changed by
walk: Add a cache for DirEntry metadataTavian Barnesbefore adoption7b5b3ec
History of this fileTake it
The walk stopped after 200 commits: lines older than 04bcd54 point at it.
Refactor file types check to be on impl of FileTypesThayne McCombsbefore adoption115ae93
lines 1–3why, one step back1use crate::filesystem;2use crate::walk;3Also add NetBSD and OpenBSDTobias Kortkampbefore adoption04bcd54
lines 4–24why, one step back4/// Whether or not to show5pub struct FileTypes {6 pub files: bool,7 pub directories: bool,8 pub symlinks: bool,9 pub sockets: bool,10 pub pipes: bool,11 pub executables_only: bool,12 pub empty_only: bool,13}1415impl Default for FileTypes {16 fn default() -> FileTypes {17 FileTypes {18 files: false,19 directories: false,20 symlinks: false,21 sockets: false,22 pipes: false,23 executables_only: false,24 empty_only: false,Refactor file types check to be on impl of FileTypesThayne McCombsbefore adoption115ae93
lines 25–39why, one step back25 }26 }27}2829impl FileTypes {30 pub fn should_ignore(&self, entry: &walk::DirEntry) -> bool {31 if let Some(ref entry_type) = entry.file_type() {32 (!self.files && entry_type.is_file())33 || (!self.directories && entry_type.is_dir())34 || (!self.symlinks && entry_type.is_symlink())35 || (!self.sockets && filesystem::is_socket(*entry_type))36 || (!self.pipes && filesystem::is_pipe(*entry_type))37 || (self.executables_only38 && !entry39 .metadata()walk: Add a cache for DirEntry metadataTavian Barnesbefore adoption7b5b3ec
line 40why, one step back40 .map(|m| filesystem::is_executable(m))Refactor file types check to be on impl of FileTypesThayne McCombsbefore adoption115ae93
line 41why, one step back41 .unwrap_or(false))Remove an unnecessary reference. (#864)Thayne McCombsbefore adoption00eb646
line 42why, one step back42 || (self.empty_only && !filesystem::is_empty(entry))Refactor file types check to be on impl of FileTypesThayne McCombsbefore adoption115ae93
lines 43–49why, one step back43 || !(entry_type.is_file()44 || entry_type.is_dir()45 || entry_type.is_symlink()46 || filesystem::is_socket(*entry_type)47 || filesystem::is_pipe(*entry_type))48 } else {49 trueAlso add NetBSD and OpenBSDTobias Kortkampbefore adoption04bcd54
lines 50–52why, one step back50 }51 }52}