Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an IO::Path.dir-with-entries method
Checking whether a directory has entries in it, can be checked by doing e.g. an "if .dir.head {". However, this will leak resources as the iterator that runs "dir" will never be finished, and thus the underlying directory handle will also never be closed. Alternately, doing an "if dir.elems {" *would* close the underlying directory handle, but possibly after doing a lot of work if the directory in question actually contains *many* entries. This method will return a Bool that will indicate whether the IO::Path has any entries in it (:test to give a tester, default to "none(<. ..>)"). It will stop as soon as it finds a matching entry, close the directory handle, and return.
- Loading branch information