Help language development. Donate to The Perl Foundation
IO::Dir - IO::Path.dir you can close
# Won't always suit, since non-exhausted iterator holds on to an open # file descriptor until GC: 'foo'.IO.dir.say; # all good; we explicitly close the file descriptor when done .dir.say and .close with IO::Dir.open: 'foo';
IO::Path.dir does the job well for
most cases, however, there's an edge case where it's no good:
If you're in that category, then good news!
IO::Dir gives you a
file descriptor you can close without relying on GC or having to fully
Creates a new
IO::Dir object. Takes no args.
Opens for reading directory given as a positional argument, which can be
any object that can be coerced to
.IO method. Defaults to
.close the invocant if it was previously opened.
$dir1.open; $dir2.open: 'foo';
Takes similar arguments as
IO::Path.dir, that have the same
meaning, returning the same type of
.close the invocant when
the result is exhausted.
The additional arguments are boolean
:Str that control whether to return absolute paths when dir was opened via an absolute path and whether to
return paths as
Note: you cannot call
.dir more than once; re-open the
invocant or create a new
IO::Dir if you need that. Will die if called on
# Explicit close: .dir.say and .close with IO::Dir.open: 'foo'; # Implicit close (arrays are mostly-eager, so our Seq is exhausted here) my @files = IO::Dir.open('foo').dir;
Closes an open
IO::Dir, freeing the file descriptor.
.dir.say and .close with IO::Dir.open: 'foo';
Fork this module on GitHub: https://github.com/raku-community-modules/IO-Dir
To report bugs or request features, please use https://github.com/raku-community-modules/IO-Dir/issues
Zoffix Znet (http://perl6.party/)
You can use and distribute this module under the terms of the
The Artistic License 2.0. See the
LICENSE file included in this
distribution for complete details.
META6.json file of this distribution may be distributed and modified
without restrictions or attribution.