Looking for a crate

I need to build a file walker from a set of glob patterns, but I prefer not to build it myself, so I would appreciate if there is already one that satisfies the following requirements:

  • Deterministic filename order, regardless of environment, OS, etc.
  • Do not walk into ignored directories, for example:
    • foo/** will never match any file in bar/, so it shouldn't walk into bar/
    • !foo and !**/foo will never match any file in foo/, so it shouldn' walk into foo/

Sounds like you're looking for the ignore crate.

The ignore crate provides a fast recursive directory iterator that respects various filters such as globs, file types and .gitignore files.

I don't think it is what I need. I have read the documentation and do not find a way to convert a set of glob patterns to a list (or iterator) of filenames.

I had tried globwalk, but it does not give me deterministic filename order.

1 Like

Probably the only way to achieve that is to read in all the files into a list, then sort them the way you need it.
The underlying OS function simply don't provide the guarantee of any order.

1 Like

That would be very slow. But I guess there really is no other way.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.