Skip to content
Myr

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

4 files+18 added−16 removed

modified:src/fshelper/mod.rs+13 added
7 unmodified lines
89use std::env::current_dir;10use std::path::{Path, PathBuf};11use std::io;12use std::fs;13#[cfg(any(unix, target_os = "redox"))]14use std::os::unix::fs::PermissionsExt;1516pub fn path_absolute_form(path: &Path) -> io::Result<PathBuf> {17 if path.is_absolute() {18 Ok(path.to_path_buf())
25 unmodified lines
44 } else {45 path.is_dir() && path.canonicalize().is_ok()46 }47}4849#[cfg(any(unix, target_os = "redox"))]50pub fn is_executable(md: &fs::Metadata) -> bool {51 md.permissions().mode() & 0o111 != 052}5354#[cfg(windows)]55pub fn is_executable(_: &fs::Metadata) -> bool {56 false57}
modified:src/internal.rs-13 removed
8 unmodified lines
9use std::ffi::OsString;10use std::process;11use std::time;12use std::io::Write;13use std::fs;14#[cfg(any(unix, target_os = "redox"))]15use std::os::unix::fs::PermissionsExt;1314use exec::CommandTemplate;15use lscolors::LsColors;16use regex_syntax::Parser;
156 unmodified lines
173 args174 })175}176180#[cfg(any(unix, target_os = "redox"))]181pub fn is_executable(md: &fs::Metadata) -> bool {182 md.permissions().mode() & 0o111 != 0183}184185#[cfg(windows)]186pub fn is_executable(_: &fs::Metadata) -> bool {187 false188}189177#[cfg(test)]178fn oss(v: &str) -> OsString {179 OsString::from(v)180}
73 unmodified lines
modified:src/output.rs+2 added-1 removed
4 unmodified lines
5// at your option. All files in the project carrying such6// notice may not be copied, modified, or distributed except7// according to those terms.89use internal::{is_executable, FdOptions, EXITCODE_ERROR, EXITCODE_SIGINT};9use internal::{FdOptions, EXITCODE_ERROR, EXITCODE_SIGINT};10use fshelper::is_executable;11use lscolors::LsColors;1213use std::process;14use std::io::{self, Write};
120 unmodified lines
modified:src/walk.rs+3 added-2 removed
8 unmodified lines
9extern crate ctrlc;1011use exec;12use fshelper;13use internal::{error, is_executable, FdOptions, EXITCODE_SIGINT, MAX_BUFFER_LENGTH};13use internal::{error, FdOptions, EXITCODE_SIGINT, MAX_BUFFER_LENGTH};14use output;1516use std::process;17use std::path::PathBuf;
183 unmodified lines
201 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