Skip to content
Myr

Implement --type executable on Windows

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes #1051.

authored by Tavian Barnes · committed by David Peter · parent 3e68733 · Browse files · 5 files+23 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+23 added−4 removed

  • other:+23 added−4 removed

5 files+23 added−4 removed

modified:src/filesystem.rs+6 added-3 removed
5 unmodified lines
6#[cfg(any(unix, target_os = "redox"))]7use std::os::unix::fs::{FileTypeExt, PermissionsExt};8use std::path::{Path, PathBuf};910#[cfg(windows)]11use faccess::PathExt as _;1213use normpath::PathExt;1415use crate::dir_entry;16
27 unmodified lines
44 path.is_dir() && (path.file_name().is_some() || path.normalize().is_ok())45}4647#[cfg(any(unix, target_os = "redox"))]45pub fn is_executable(md: &fs::Metadata) -> bool {48pub fn is_executable(_: &Path, md: &fs::Metadata) -> bool {49 md.permissions().mode() & 0o111 != 050}5152#[cfg(windows)]50pub fn is_executable(_: &fs::Metadata) -> bool {51 false53pub fn is_executable(path: &Path, _: &fs::Metadata) -> bool {54 path.executable()55}5657pub fn is_empty(entry: &dir_entry::DirEntry) -> bool {58 if let Some(file_type) = entry.file_type() {
93 unmodified lines
modified:src/filetypes.rs+1 added-1 removed
22 unmodified lines
23 || (!self.pipes && filesystem::is_pipe(*entry_type))24 || (self.executables_only25 && !entry26 .metadata()27 .map(filesystem::is_executable)27 .map(|md| filesystem::is_executable(entry.path(), md))28 .unwrap_or(false))29 || (self.empty_only && !filesystem::is_empty(entry))30 || !(entry_type.is_file()31 || entry_type.is_dir()
8 unmodified lines
modified:Cargo.lock+12 added
175 unmodified lines
176 "winapi",177]178179[[package]]180name = "faccess"181version = "0.2.4"182source = "registry+https://github.com/rust-lang/crates.io-index"183checksum = "59ae66425802d6a903e268ae1a08b8c38ba143520f227a205edf4e9c7e3e26d5"184dependencies = [185 "bitflags",186 "libc",187 "winapi",188]189190[[package]]191name = "fd-find"192version = "8.4.0"193dependencies = [194 "ansi_term",
5 unmodified lines
200 "clap_complete",201 "ctrlc",202 "diff",203 "dirs-next",204 "faccess",205 "filetime",206 "globset",207 "humantime",208 "ignore",
632 unmodified lines
modified:Cargo.toml+3 added
modified:CHANGELOG.md+1 added
1# Upcoming release23## Features45- `--type executable`/`-t` now works on Windows, see #1051 and #106167## Bugfixes89- fd returns an error when current working directory does not exist while a search path is specified, see #1072 (@vijfhoek)
600 unmodified lines