mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-19 02:10:34 +01:00
Move is_executable to internal module
This commit is contained in:
parent
67f6fdf6a7
commit
2cf8e7b8a5
3 changed files with 17 additions and 17 deletions
|
@ -10,6 +10,9 @@ use std::ffi::OsString;
|
|||
use std::process;
|
||||
use std::time;
|
||||
use std::io::Write;
|
||||
use std::fs;
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
use exec::CommandTemplate;
|
||||
use lscolors::LsColors;
|
||||
|
@ -174,6 +177,16 @@ where
|
|||
})
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
pub fn is_executable(md: &fs::Metadata) -> bool {
|
||||
md.permissions().mode() & 0o111 != 0
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn is_executable(_: &fs::Metadata) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn oss(v: &str) -> OsString {
|
||||
OsString::from(v)
|
||||
|
|
|
@ -6,17 +6,15 @@
|
|||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use internal::{FdOptions, EXITCODE_ERROR, EXITCODE_SIGINT};
|
||||
use internal::{is_executable, FdOptions, EXITCODE_ERROR, EXITCODE_SIGINT};
|
||||
use lscolors::LsColors;
|
||||
|
||||
use std::{fs, process};
|
||||
use std::process;
|
||||
use std::io::{self, Write};
|
||||
use std::ops::Deref;
|
||||
use std::path::{self, Component, Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
use ansi_term;
|
||||
|
||||
|
@ -133,13 +131,3 @@ fn get_path_style<'a>(path: &Path, ls_colors: &'a LsColors) -> Option<&'a ansi_t
|
|||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
pub fn is_executable(md: &fs::Metadata) -> bool {
|
||||
md.permissions().mode() & 0o111 != 0
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn is_executable(_: &fs::Metadata) -> bool {
|
||||
false
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ extern crate ctrlc;
|
|||
|
||||
use exec;
|
||||
use fshelper;
|
||||
use internal::{error, FdOptions, EXITCODE_SIGINT, MAX_BUFFER_LENGTH};
|
||||
use internal::{error, is_executable, FdOptions, EXITCODE_SIGINT, MAX_BUFFER_LENGTH};
|
||||
use output;
|
||||
|
||||
use std::process;
|
||||
|
@ -202,8 +202,7 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) {
|
|||
if (entry_type.is_file() && !file_types.files)
|
||||
|| (entry_type.is_dir() && !file_types.directories)
|
||||
|| (entry_type.is_symlink() && !file_types.symlinks)
|
||||
|| (entry.metadata().is_ok()
|
||||
&& !output::is_executable(&entry.metadata().unwrap())
|
||||
|| (entry.metadata().is_ok() && !is_executable(&entry.metadata().unwrap())
|
||||
&& file_types.executables_only)
|
||||
{
|
||||
return ignore::WalkState::Continue;
|
||||
|
|
Loading…
Reference in a new issue