lf icon indicating copy to clipboard operation
lf copied to clipboard

Hidden file patterns for windows

Open Catalyn45 opened this issue 1 year ago • 1 comments

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 avatar Apr 08 '24 07:04 Catalyn45

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.

joelim-work avatar Apr 08 '24 09:04 joelim-work