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

respect hidden file attribute #1154

Closed
ghost opened this issue Jan 8, 2019 · 2 comments
Closed

respect hidden file attribute #1154

ghost opened this issue Jan 8, 2019 · 2 comments
Labels
bug A bug.

Comments

@ghost
Copy link

ghost commented Jan 8, 2019

currently RipGrep considers a hidden file something starting with ., which is a
long time Linux convention

/// Returns true if and only if this file path is considered to be hidden.
#[cfg(not(unix))]
pub fn is_hidden<P: AsRef<Path>>(path: P) -> bool {
if let Some(name) = file_name(path.as_ref()) {
name.to_str().map(|s| s.starts_with(".")).unwrap_or(false)
} else {
false
}
}

However the Windows convention of the hidden file attribute is not recognized by
RipGrep. So if you have some files on Windows with the hidden file attribute,
RipGrep will always show them regardless, unless they also happen to start with .

@BurntSushi
Copy link
Owner

Seems reasonable to me. It looks like we need to check whether the file attributes contain FILE_ATTRIBUTE_HIDDEN.

The one concern I have here is that if this is done naively, it will introduce an additional stat call for every file ripgrep looks at, by default. We should try to avoid that by looking for an existing stat call and reusing its information.

@ghost
Copy link
Author

ghost commented Jan 8, 2019

@BurntSushi thanks for fast response

it probably goes without saying, but i am of that opinion that even if this is
implemented it should not be the default, as it seems we are talking about
a performance hit

users should need to opt into this, with the default remaining the faster
option. thank you!

BurntSushi added a commit to BurntSushi/winapi-util that referenced this issue Jan 27, 2019
This adds a convenience routine for checking whether file information
has the hidden attribute set.

This was motivated by this bug report against ripgrep:
BurntSushi/ripgrep#1154
BurntSushi added a commit that referenced this issue Jan 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug.
Projects
None yet
Development

No branches or pull requests

1 participant