NAME

File::Fu::Dir - a directoryname object

SYNOPSIS

Constructor

new

my $dir = File::Fu::Dir->new($path);

my $dir = File::Fu::Dir->new(@path);

file_class

Return the corresponding file class for this dir object.

my $fc = $class->file_class;

Methods

stringify

my $string = $dir->stringify;

file

Create a filename object with $dir as its parent.

my $file = $dir->file($filename);

my $file = $dir + $filename;

append

$newdir = $dir->append('.tmp');

$dir .= "something";

subdir

$newdir = $dir->subdir('foo');

$dir /= 'foo';

part

Returns the $i'th part of the directory list.

my $part = $dir->part($i);

$dir->part(-1) is like $dir->basename, but not an object and not quite like File::Basename::basename() when it comes to the / directory.

map

$dir->map(sub {...});

Properties

is_cwd

True if the $dir represents a relative (e.g. '.') directory.

my $bool = $dir->is_cwd;

basename

Returns the last part of the path as a Dir object.

my $bit = $dir->basename;

dirname

Returns the parent parts of the path as a Dir object.

my $parent = $dir->dirname;

Doing stuff

open

Calls opendir(), but throws an error if it fails.

my $dh = $dir->open;

Returns a directory handle, for e.g. readdir().

my @files = map({$dir + $_} grep({$_ !~ m/^\./} readdir($dh)));

listing

my @paths = $dir->listing(all => 1);

iterate_listing

my $subref = $dir->iterate_listing(all => 1);

contents

Equivelant to readdir. With the 'all' option true, returns hidden names too (but not the '.' and '..' entries.)

The return values are strings, not File::Fu objects.

my @names = $dir->contents(all => 1);

iterate_contents

Returns a subref which will iterate over the directory's contents.

my $subref = $dir->iterate_contents(all => 1);

AUTHOR

Eric Wilhelm @ <ewilhelm at cpan dot org>

http://scratchcomputing.com/

BUGS

If you found this module on CPAN, please report any bugs or feature requests through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

If you pulled this development version from my /svn/, please contact me directly.

COPYRIGHT

Copyright (C) 2008 Eric L. Wilhelm, All Rights Reserved.

NO WARRANTY

Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.

LICENSE

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