whitequark / rust-xdg

A library that makes it easy to follow the X Desktop Group specifications
https://wiki.freedesktop.org/www/Specifications/
Apache License 2.0
154 stars 30 forks source link

`list_data_files` should follow symlinks #36

Closed piegamesde closed 1 year ago

piegamesde commented 3 years ago

xdg.list_local_files will simply list all symlinks contained in that directory, instead of providing their targets' content. Symlink-joining folders in a data directory is a rather common pattern, especially when using Nix (although I just ran into this in a different context).

whitequark commented 3 years ago

Would you be willing to prepare a PR?

piegamesde commented 3 years ago

I had a look at the code and noticed that it didn't recurse into sub-directories. Thus, it kind of makes sense if the code lists some entries as symlinks if there are any. We could resolve them of course, but what for? The remaining cases (the traversal to the directory itself) are already resolved by std::fs::read_dir, see #21.

As far as I can tell, recursive walks are a bit out of scope for this crate, especially as walkdir best provides that functionality. I'll see if I can come up with some additions that help with my use cases. Sadly, changing the return type of many methods from Vec to impl Iterator would be a breaking change.

whitequark commented 1 year ago

It seems like the issue has been resolved to the extent of the scope.