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

Hidden file patterns for windows #1683

Open
Catalyn45 opened this issue Apr 8, 2024 · 1 comment · May be fixed by #1684
Open

Hidden file patterns for windows #1683

Catalyn45 opened this issue Apr 8, 2024 · 1 comment · May be fixed by #1684

Comments

@Catalyn45
Copy link
Contributor

Hello,

I noticed on Windows that when checking if a file is hidden we directly check the file attributes and we ignore the hiddenfiles parameter.

func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
	ptr, err := windows.UTF16PtrFromString(filepath.Join(path, f.Name()))
	if err != nil {
		return false
	}
	attrs, err := windows.GetFileAttributes(ptr)
	if err != nil {
		return false
	}
	return attrs&windows.FILE_ATTRIBUTE_HIDDEN != 0
}

While this is the correct way to check if a file is hidden on windows, I think we should also take into account the hiddenfiles parameter so we can allow custom file patterns (ex. __pycache__, obj) as we can do on Linux.

@Catalyn45 Catalyn45 changed the title Hidden files patterns for windows Hidden file patterns for windows Apr 8, 2024
@joelim-work
Copy link
Collaborator

I am not against the idea, but since there are now two criteria involved (hiddenfiles and FILE_ATTRIBUTE_HIDDEN), should a given file only need to satisfy one criteria to be considered hidden?

I think the natural answer here would be yes, and you can simply append the logic from os.go. If more complex behavior is required, then it may be possible to specify a special marker for the hiddenfiles option to indicate files with the hidden attribute set, but it's probably not worth considering at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants