Move is_executable to internal module
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by sharkdp · committed by David Peter · parent 67f6fdf · Browse files · 3 files·+17 added−17 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+17 added−17 removed
- other:+17 added−17 removed
Provenance
- Commit
2cf8e7b- Tree
d427c7d- Author
sharkdp <davidpeter@web.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
67f6fdf
3 files changed+17 added−17 removed
modified:src/internal.rs+13 added
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;16 17 use exec::CommandTemplate;18 use lscolors::LsColors;19 use regex_syntax::Parser;156 unmodified lines176 args177 })178 }179 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+190 #[cfg(test)]191 fn oss(v: &str) -> OsString {192 OsString::from(v)193 }73 unmodified linesmodified:src/output.rs+2 added-14 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::{FdOptions, EXITCODE_ERROR, EXITCODE_SIGINT};9+use internal::{is_executable, FdOptions, EXITCODE_ERROR, EXITCODE_SIGINT};10 use lscolors::LsColors;11 12-use std::{fs, process};12+use std::process;13 use std::io::{self, Write};14 use std::ops::Deref;15 use std::path::{self, Component, Path, PathBuf};16 use std::sync::Arc;17 use std::sync::atomic::{AtomicBool, Ordering};18-#[cfg(any(unix, target_os = "redox"))]19-use std::os::unix::fs::PermissionsExt;18 19 use ansi_term;20 21 /// Remove the `./` prefix from a path.108 unmodified lines130 } else {131 None132 }133 }136-137-#[cfg(any(unix, target_os = "redox"))]138-pub fn is_executable(md: &fs::Metadata) -> bool {139- md.permissions().mode() & 0o111 != 0140-}141-142-#[cfg(windows)]143-pub fn is_executable(_: &fs::Metadata) -> bool {144- false145-}modified:src/walk.rs+2 added-3 removed
8 unmodified lines9 extern crate ctrlc;10 11 use exec;12 use fshelper;13-use internal::{error, FdOptions, EXITCODE_SIGINT, MAX_BUFFER_LENGTH};13+use internal::{error, is_executable, 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()206- && !output::is_executable(&entry.metadata().unwrap())205+ || (entry.metadata().is_ok() && !is_executable(&entry.metadata().unwrap())206 && file_types.executables_only)207 {208 return ignore::WalkState::Continue;209 } else if !(entry_type.is_file() || entry_type.is_dir()54 unmodified lines