The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Chj::xopendir

SYNOPSIS

    use Chj::xopendir;
    {
        my $dir = xopendir "/foo";
        while (defined(my $item = $dir->read)) {
            print $item;
        }
    } # $dir is closed automatically (issuing a warning on error)

DESCRIPTION

Something like IO::Dir, but more lightweight (IO::Dir takes about 0.3 seconds to load on my laptop, whereas this module takes less than 30ms), and with functions/methods that throw (currently untyped) exceptions on error.

FUNCTIONS

xopendir ("path")

Open the given dir or croak on errors. Returns an anonymous symbol blessed into Chj::xopendir::dir, which can be used both as object or filehandle (more correctly: anonymous glob) (? always? Perl is a bit complicated when handling filehandles in indirect object notation).

perhaps_opendir ($path)

Try to open given directory path, if successful return the filehandle, otherwise return () and leave $! set.

perhaps_xopendir ($path)

Same as perhaps_opendir but throw exception on all errors except for ENOENT.

CLASS METHODS

new ("path")

Same as xopendir, but in object oriented notation (overridable).

OBJECT METHODS

read
xread

Read one dir entry in scalar context, all entries in list context. xread croaks if it detects an error, though it's quite unsure if that really works (see also module source).

nread
xnread

Same as read/xread but discard "." and ".." entries.

xclose

Close dirhandle and croak on error. (If not called before descruction of the object, the filehandle is closed anyway, but only a warning is issued upon errors in that case.)

SEE ALSO

Chj::xopen

NOTE

This is alpha software! Read the status section in the package README or on the website.