changed executable=> executable_only

This commit is contained in:
Pramod Bisht 2018-03-25 15:49:51 +05:30 committed by David Peter
parent b1e48efc4a
commit 8ce127e443
3 changed files with 8 additions and 4 deletions

View file

@ -22,7 +22,7 @@ pub struct FileTypes {
pub files: bool,
pub directories: bool,
pub symlinks: bool,
pub executables: bool,
pub executables_only: bool,
}
impl Default for FileTypes {
@ -31,7 +31,7 @@ impl Default for FileTypes {
files: false,
directories: false,
symlinks: false,
executables: false,
executables_only: false,
}
}
}

View file

@ -161,7 +161,10 @@ fn main() {
"f" | "file" => file_types.files = true,
"d" | "directory" => file_types.directories = true,
"l" | "symlink" => file_types.symlinks = true,
"x" | "executable" => file_types.executables = true,
"x" | "executable" => {
file_types.executables_only = true;
file_types.files = true;
},
_ => unreachable!(),
}
}

View file

@ -196,12 +196,13 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) {
}
// Filter out unwanted file types.
if let Some(ref file_types) = config.file_types {
if let Some(ref entry_type) = entry.file_type() {
if (entry_type.is_file() && !file_types.files)
|| (entry_type.is_dir() && !file_types.directories)
|| (entry_type.is_symlink() && !file_types.symlinks)
|| (output::is_executable(&entry.metadata().unwrap()) && !file_types.executables)
|| (entry.metadata().is_ok() && !output::is_executable(&entry.metadata().unwrap()) && file_types.executables_only)
{
return ignore::WalkState::Continue;
} else if !(entry_type.is_file() || entry_type.is_dir()