| Path-Extended documentation | Contained in the Path-Extended distribution. |
Path::Extended::Class::Dir
Path::Extended::Class::Dir behaves pretty much like Path::Class::Dir and can do some extra things. See appropriate pods for details.
change how to stringify internally and return the file object (instead of the path itself).
create a directory with File::Path, and return the result (instead of the directory object itself).
remove a directory with File::Path, and return the result (instead of the directory object itself).
returns parts of the path. See Path::Class::Dir for details.
returns a temporary file handle (and its corresponding file name in a list context). See Path::Class::Dir and File::Temp for details
does nothing but returns the object to chain. Path::Extended::Class should always return a canonical path.
does nothing but returns the object to chain. Path::Extended::Class doesn't support foreign path expressions.
returns a new Path::Extended::Class::Dir object whatever the type is specified.
Kenichi Ishigaki, <ishigaki@cpan.org>
Copyright (C) 2009 by Kenichi Ishigaki.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Path-Extended documentation | Contained in the Path-Extended distribution. |
package Path::Extended::Class::Dir; use strict; use warnings; use base qw( Path::Extended::Dir ); sub _initialize { my ($self, @args) = @_; return if @args && !defined $args[0]; my $dir = @args ? File::Spec->catdir( @args ) : File::Spec->curdir; $self->{path} = $self->_unixify( File::Spec->rel2abs($dir) ); $self->{is_dir} = 1; $self->{_compat} = 1; $self->{_absolute} = File::Spec->file_name_is_absolute( $dir ); $self; } sub new_foreign { my ($class, $type, @args) = @_; $class->new(@args); } sub absolute { my $self = shift; $self->{_base} = undef; $self; } sub relative { my $self = shift; my $base = @_ % 2 ? shift : undef; my %options = @_; $self->{_base} = $base || $options{base} || File::Spec->curdir; $self; } sub cleanup { shift } # is always clean sub as_foreign { shift } # does nothing sub dir_list { my $self = shift; my @parts = $self->_parts; return @parts unless @_; my $offset = shift; $offset = @parts + $offset if $offset < 0; return wantarray ? @parts[$offset .. $#parts] : $parts[$offset] unless @_; my $length = shift; $length = @parts + $length - $offset if $length < 0; return @parts[$offset .. $length + $offset - 1]; } sub tempfile { my $self = shift; require File::Temp; return File::Temp::tempfile(@_, DIR => $self->stringify); } sub mkdir {require File::Path; File::Path::mkpath(shift->path, @_)} sub rmdir {require File::Path; File::Path::rmtree(shift->path, @_)} *mkpath = \&mkdir; *rmtree = *remove = \&rmdir; 1; __END__