Skip to content

Commit

Permalink
cfg flag for ca
Browse files Browse the repository at this point in the history
  • Loading branch information
matrixhead committed Jul 6, 2024
1 parent 1128a36 commit 709fec0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,17 @@ pub trait Colorable {
/// Try to get the metadata for this file.
fn metadata(&self) -> Option<Metadata>;

#[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 {
Expand Down

0 comments on commit 709fec0

Please sign in to comment.