NAME

Path::Extended::Dir

SYNOPSIS

use Path::Extended::Dir;

my $dir = Path::Extended::Dir->new('path/to/somewhere');
my $parent_dir = Path::Extended::Dir->new_from_file('path/to/some.file');

foreach my $file ( $dir->find('*.txt') ) {
  print $file->relative, "\n";  # each $file is a L<Path::Extended::File> object.
}

DESCRIPTION

This class implements several directory-specific methods. See also Path::Class::Entity for common methods like copy and move.

METHODS

new, new_from_file

takes a path or parts of a path of a directory (or a file in the case of new_from_file), and creates a Path::Extended::Dir object. If the path specified is a relative one, it will be converted to the absolute one internally.

open, close, read, seek, tell, rewind

are simple wrappers of the corresponding built-in functions (with the trailing 'dir').

mkdir, mkpath

makes the directory via File::Path::mkpath.

rmdir, rmtree, remove

removes the directory via File::Path::rmtree.

find, find_dir

takes a File::Find::Rule's rule and a hash option, and returns Path::Extended::* objects of the matched files (find) or directories (find_dir) under the directory the $self object points to. Options are:

callback

You can pass a code reference to filter the objects.

next

while (my $file = $dir->next) {
  next unless -f $file;
  $file->openr or die "Can't read $file: $!";
  ...
}

returns a Path::Extended::Dir or Path::Extended::File object to iterate through directory contents (or undef when there's no more items in the directory). The directory will be open with the first next, and close with the last next.

children

returns a list of Path::Extended::Class::File and/or Path::Extended::Class::Dir objects listed in the directory. See Path::Class::Dir for details.

AUTHOR

Kenichi Ishigaki, <ishigaki@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2008 by Kenichi Ishigaki.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.