From 709fec07eb252c5c044d3a13f2f75261089660ac Mon Sep 17 00:00:00 2001 From: mhead Date: Sat, 6 Jul 2024 19:12:51 +0530 Subject: [PATCH] cfg flag for ca --- Cargo.toml | 1 + src/lib.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 75172b2..f4cad33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ ansi_term = { version = "0.12", optional = true } nu-ansi-term = { version = "0.50", optional = true } crossterm = { version = "0.27", optional = true } owo-colors = { version = "4.0", optional = true } +[target.'cfg(target_os = "linux")'] capctl = "0.2.4" [dev-dependencies] diff --git a/src/lib.rs b/src/lib.rs index 0cebe4f..05257d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -199,12 +199,17 @@ pub trait Colorable { /// Try to get the metadata for this file. fn metadata(&self) -> Option; + #[cfg(target_os = "linux")] fn has_capabilities(&self) -> bool { matches!( capctl::caps::FileCaps::get_for_file(self.path()), Ok(Some(..)) ) } + #[cfg(not(target_os = "linux"))] + fn has_capabilities(&self) -> bool { + false + } } impl Colorable for DirEntry {