Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter files hidden by attribute on MacOS #405

Open
casey opened this issue Apr 21, 2020 · 0 comments
Open

Filter files hidden by attribute on MacOS #405

casey opened this issue Apr 21, 2020 · 0 comments

Comments

@casey
Copy link
Owner

casey commented Apr 21, 2020

I opened a PR on ripgrep BurntSushi/ripgrep#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:

  fn hidden(path: &Path) -> Result<bool, Error> {
    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)
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant