IO::Dir
Native Rust implementation built into the interpreter. Runtime: PP. See original documentation for the full Perl reference.
Provides object-oriented directory operations compatible with Perl’s IO::Dir.
IO::Dir objects are blessed hashrefs. The __dh_id key stores the directory
handle ID (u64) that maps to an entry in DIRHANDLE_TABLE.
Functions
DESTROY
Destructor. Automatically closes the directory handle when the object goes out of scope.
DIR_UNLINK
Exportable constant (value 1). Used by tie-based directory operations.
close
Closes the directory handle and removes it from DIRHANDLE_TABLE.
$d->close();
new
Constructor. With no arguments, returns an unopened IO::Dir object. With a directory name, opens the directory and returns a blessed handle.
use IO::Dir;
my $d = IO::Dir->new("/tmp");
my $d = IO::Dir->new();
open
Opens (or re-opens) a directory on an existing IO::Dir object. Closes any previously opened directory first. Returns 1 on success, undef on failure.
my $d = IO::Dir->new;
$d->open("/tmp") or die $!;
read
Reads the next directory entry. Returns the entry name as a string, or undef at end-of-directory.
while (defined(my $entry = $d->read)) {
```perl
print "$entry\n";
}
### rewind
Resets the directory read position to the beginning.
```perl
$d->rewind();
seek
Sets the directory read position to a given offset (as returned
by tell).
$d->seek($saved_pos);
tell
Returns the current directory read position, or -1 on error.
my $pos = $d->tell();