casey / casey/intermodal

Filter files hidden by attribute on MacOS

Open
#405 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
659
Forks
36
Avg merge
18m
Merged PRs (30d)
2

Description

I opened a PR on ripgrep https://github.com/BurntSushi/ripgrep/pull/1557 to add a `filter_entry` method to `ignore::WalkBuilder`. Once that lands we can go back to filtering files hidden by attribute on MacOS. An improved implementation of that, without needing `unsafe` or `libc::stat` is:

```rust
fn hidden(path: &Path) -> Result {
use std::os::macos::fs::MetadataExt;

let metadata = path.metadata().context(error::Filesystem { path })?;

const HIDDEN_MASK_MAC: u32 = 0x0000_8000;

Ok(metadata.st_flags() & HIDDEN_MASK_MAC != 0)
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.