Move is_executable to fshelper module
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by sharkdp · committed by sharkdp · parent 9d840dd · Browse files · 4 files·+18 added−16 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+18 added−16 removed
- other:+18 added−16 removed
Provenance
- Commit
f9a3258- Tree
21b94d9- Author
sharkdp <davidpeter@web.de>- Committer
sharkdp <davidpeter@web.de>- Parent
9d840dd
4 files changed+18 added−16 removed
modified:src/fshelper/mod.rs+13 added
7 unmodified lines8 9 use std::env::current_dir;10 use std::path::{Path, PathBuf};11 use std::io;12+use std::fs;13+#[cfg(any(unix, target_os = "redox"))]14+use std::os::unix::fs::PermissionsExt;15 16 pub fn path_absolute_form(path: &Path) -> io::Result<PathBuf> {17 if path.is_absolute() {18 Ok(path.to_path_buf())25 unmodified lines44 } else {45 path.is_dir() && path.canonicalize().is_ok()46 }47 }48+49+#[cfg(any(unix, target_os = "redox"))]50+pub fn is_executable(md: &fs::Metadata) -> bool {51+ md.permissions().mode() & 0o111 != 052+}53+54+#[cfg(windows)]55+pub fn is_executable(_: &fs::Metadata) -> bool {56+ false57+}modified:src/internal.rs-13 removed
8 unmodified lines9 use std::ffi::OsString;10 use std::process;11 use std::time;12 use std::io::Write;13-use std::fs;14-#[cfg(any(unix, target_os = "redox"))]15-use std::os::unix::fs::PermissionsExt;13 14 use exec::CommandTemplate;15 use lscolors::LsColors;16 use regex_syntax::Parser;156 unmodified lines173 args174 })175 }176 180-#[cfg(any(unix, target_os = "redox"))]181-pub fn is_executable(md: &fs::Metadata) -> bool {182- md.permissions().mode() & 0o111 != 0183-}184-185-#[cfg(windows)]186-pub fn is_executable(_: &fs::Metadata) -> bool {187- false188-}189-177 #[cfg(test)]178 fn oss(v: &str) -> OsString {179 OsString::from(v)180 }73 unmodified linesmodified:src/output.rs+2 added-1 removed
4 unmodified lines5 // at your option. All files in the project carrying such6 // notice may not be copied, modified, or distributed except7 // according to those terms.8 9-use internal::{is_executable, FdOptions, EXITCODE_ERROR, EXITCODE_SIGINT};9+use internal::{FdOptions, EXITCODE_ERROR, EXITCODE_SIGINT};10+use fshelper::is_executable;11 use lscolors::LsColors;12 13 use std::process;14 use std::io::{self, Write};120 unmodified linesmodified:src/walk.rs+3 added-2 removed
8 unmodified lines9 extern crate ctrlc;10 11 use exec;12 use fshelper;13-use internal::{error, is_executable, FdOptions, EXITCODE_SIGINT, MAX_BUFFER_LENGTH};13+use internal::{error, FdOptions, EXITCODE_SIGINT, MAX_BUFFER_LENGTH};14 use output;15 16 use std::process;17 use std::path::PathBuf;183 unmodified lines201 if let Some(ref entry_type) = entry.file_type() {202 if (entry_type.is_file() && !file_types.files)203 || (entry_type.is_dir() && !file_types.directories)204 || (entry_type.is_symlink() && !file_types.symlinks)205- || (entry.metadata().is_ok() && !is_executable(&entry.metadata().unwrap())205+ || (entry.metadata().is_ok()206+ && !fshelper::is_executable(&entry.metadata().unwrap())207 && file_types.executables_only)208 {209 return ignore::WalkState::Continue;210 } else if !(entry_type.is_file() || entry_type.is_dir()54 unmodified lines