diff --git a/src/fs/file.rs b/src/fs/file.rs index cd972e322..930c98f70 100644 --- a/src/fs/file.rs +++ b/src/fs/file.rs @@ -25,7 +25,6 @@ use std::time::SystemTime; use chrono::prelude::*; use log::{debug, error, trace}; -#[cfg(unix)] use std::sync::LazyLock; use crate::fs::dir::Dir; @@ -353,6 +352,25 @@ impl<'dir> File<'dir> { (md.permissions().mode() & bit) == bit } + #[cfg(windows)] + pub fn is_executable_file(&self) -> bool { + use std::collections::HashSet; + use std::env; + + let Some(ext) = self.ext.as_ref() else { + return false; + }; + + static PATHEXT: LazyLock> = LazyLock::new(|| { + env::var("PATHEXT") + .unwrap_or_default() + .split(';') + .map(|s| s[1..].to_string()) + .collect::>() + }); + PATHEXT.contains(&ext.to_uppercase()) + } + /// Whether this file is a symlink on the filesystem. pub fn is_link(&self) -> bool { self.filetype().is_some_and(FileType::is_symlink) diff --git a/src/output/file_name.rs b/src/output/file_name.rs index 85c5e5c42..2020ee9e7 100644 --- a/src/output/file_name.rs +++ b/src/output/file_name.rs @@ -478,7 +478,6 @@ impl FileName<'_, '_, C> { return match self.file { f if f.is_mount_point() => self.colours.mount_point(), f if f.is_directory() => self.colours.directory(), - #[cfg(unix)] f if f.is_executable_file() => self.colours.executable_file(), f if f.is_link() => self.colours.symlink(), #[cfg(unix)]