Repository: eza-community/eza (language: rust)

Issue:
feat: Windows Hidden Files Support
So I installed eza on my work laptop (which unfortunately has Windows 11 installed) because I wanted a more Linux-ey way to search for files in PowerShell. 

Something that would make eza an even better alternative to PowerShell's Get-ChildItem would be to hide Windows hidden files when `-a` isn't specified. The current behaviour only hides dot files.

I don't think this would be too hard to implement as the hidden flag is included when running `eza -l` so the information is there.
![image](https://github.com/eza-community/eza/assets/127202207/86ebbcd7-6c29-4de4-8d00-031cbc2e17ca)

I may take a look into this at the weekend if I get the chance & no one has any complaints with this change.


Discussion / hints:
> I may take a look into this at the weekend if I get the chance & no one has any complaints with this change.

That would be cool to see, I'm assuming this makes sense, but if people disagree they should feel free to voice concerns in this issue.
Little bit more complicated than I'd imagined. The actual dot filter happens in the Iterator impl on `Files`, before the `File` is created. main.rs line 236 inside of `print_dirs` is the first time we unwrap the `Result<File>` so I opted to just skip pushing into `children` but I don't know if I'm a fan of this approach.
![image](https://github.com/eza-community/eza/assets/127202207/ca739bab-0bce-4fd8-9a1e-3bde91812600)

I could maybe move the error checking into these methods so `Item = Result<File ...>` becomes `Item = File` & `next_visible_file` can filter on attributes().hidden during the dot file check
![image](https://github.com/eza-community/eza/assets/127202207/8a02e19d-3ae3-41c8-9c58-fb93710a0952)

for reference next_visible_file is where it feels like the hidden file check 'belongs'
![image](https://github.com/eza-community/eza/assets/127202207/060c1d8b-e4b2-48cc-84af-2595f79edf27)

I'll give the Iterator refactoring a go tomorrow and get a PR up to get some eyes on it

Or this could work, rather than return `Some(File::from_args(...))` match on the result of from_args & skip the Windows hidden files or wrap it back up in the Option<Result<>> for the calling code to handle
![image](https://github.com/eza-community/eza/assets/127202207/4d40e792-b3f0-4cef-8838-c5afa29987f5)

I have been playing with this myself for the last half hour. I do agree that this seems like the most idiomatic place for this check...

How does that perform? I tried various other options but never that exact one
Default behaviour with `eza -l` (my alias is just ls -> eza.exe)
![image](https://github.com/eza-community/eza/assets/127202207/22cd9b28-3161-41be-81bd-7f8d6bb89936)

It does hide symlinks which differs from default ls behaviour, but in my experience symlinks aren't as important or widely used in Windows so I think I prefer this (they're also hidden in the file system by default). It does a bit better better than PowerShell's Get-ChildItem which hides hidden files and symlinks but not dot files.

Running with -a or -A gives the following:
![image](https://github.com/eza-community/eza/assets/127202207/3d1ca00d-f51f-4b8d-bd70-cf36a9cecc56)

Symlinks + Windows hidden files & folders now appear (as well as dot files).

So it doesn't behave exactly the same way as a Linux ls with the symlinks, but it behaves in a way that makes more sense inside of Windows IMO

I was wrong, it doesn't hide symlinks, it just hides Window's "file junctions" because these are marked as hidden by the system

Anyway the PR is up #225, I opted to put the whole match in the Windows block so the non-windows behaviour is hopefully a bit clearer.

Fix patch:
diff --git a/src/fs/dir.rs b/src/fs/dir.rs
index 4b1de8cc5..f00930be2 100644
--- a/src/fs/dir.rs
+++ b/src/fs/dir.rs
@@ -130,8 +130,17 @@ impl<'dir, 'ig> Files<'dir, 'ig> {
                     }
                 }
 
-                return Some(File::from_args(path.clone(), self.dir, filename, self.deref_links)
-                                 .map_err(|e| (path.clone(), e)))
+                let file = File::from_args(path.clone(), self.dir, filename, self.deref_links)
+                                 .map_err(|e| (path.clone(), e));
+
+                // Windows has its own concept of hidden files, when dotfiles are
+                // hidden Windows hidden files should also be filtered out
+                #[cfg(windows)]
+                if !self.dotfiles && file.as_ref().is_ok_and(|f| f.attributes().hidden) {
+                    continue;
+                }
+
+                return Some(file);
             }
 
             return None


Test patch: