From 8ce127e443fe10cd4778f428e29a2349bce6de6f Mon Sep 17 00:00:00 2001 From: Pramod Bisht Date: Sun, 25 Mar 2018 15:49:51 +0530 Subject: [PATCH] changed executable=> executable_only --- src/internal.rs | 4 ++-- src/main.rs | 5 ++++- src/walk.rs | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/internal.rs b/src/internal.rs index fd2b447..6b3a473 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -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, } } } diff --git a/src/main.rs b/src/main.rs index 4297d1c..d58bed1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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!(), } } diff --git a/src/walk.rs b/src/walk.rs index 58aec91..33b60ee 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -196,12 +196,13 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc, config: Arc) { } // 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()