Skip to content
Myr

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

3 files+17 added−17 removed

modified:src/internal.rs+13 added
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;1617use exec::CommandTemplate;18use lscolors::LsColors;19use regex_syntax::Parser;
156 unmodified lines
176 args177 })178}179180#[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}189190#[cfg(test)]191fn oss(v: &str) -> OsString {192 OsString::from(v)193}
73 unmodified lines
modified:src/output.rs+2 added-14 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::{FdOptions, EXITCODE_ERROR, EXITCODE_SIGINT};9use internal::{is_executable, FdOptions, EXITCODE_ERROR, EXITCODE_SIGINT};10use lscolors::LsColors;1112use std::{fs, process};12use std::process;13use std::io::{self, Write};14use std::ops::Deref;15use std::path::{self, Component, Path, PathBuf};16use std::sync::Arc;17use std::sync::atomic::{AtomicBool, Ordering};18#[cfg(any(unix, target_os = "redox"))]19use std::os::unix::fs::PermissionsExt;1819use ansi_term;2021/// Remove the `./` prefix from a path.
108 unmodified lines
130 } else {131 None132 }133}136137#[cfg(any(unix, target_os = "redox"))]138pub fn is_executable(md: &fs::Metadata) -> bool {139 md.permissions().mode() & 0o111 != 0140}141142#[cfg(windows)]143pub fn is_executable(_: &fs::Metadata) -> bool {144 false145}
modified:src/walk.rs+2 added-3 removed
8 unmodified lines
9extern crate ctrlc;1011use exec;12use fshelper;13use internal::{error, FdOptions, EXITCODE_SIGINT, MAX_BUFFER_LENGTH};13use internal::{error, is_executable, 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()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