Skip Menu |
 

This queue is for tickets about the IPC-PerlSSH CPAN distribution.

Report information
The Basics
Id: 58054
Status: resolved
Priority: 0/
Queue: IPC-PerlSSH

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: 0.15



Subject: Add rmtree and mkpath to Library::FS
Download (untitled) / with headers
text/plain 181b
From Freenode/#perl: (15:25) <bennymack> LeoNerd: did you consider adding rmtree and mkpath to FS? Or is there a problem in doing so Will indeed look into that. -- Paul Evans
Have fiiiinally got around to it. See attached patch. Will be in 0.15. -- Paul Evans
Subject: rt58054.patch
Download rt58054.patch
text/x-diff 2k
=== modified file 'lib/IPC/PerlSSH/Library/FS.pm' --- lib/IPC/PerlSSH/Library/FS.pm 2011-02-22 23:02:19 +0000 +++ lib/IPC/PerlSSH/Library/FS.pm 2011-02-23 00:46:55 +0000 @@ -1,7 +1,7 @@ # You may distribute under the terms of either the GNU General Public License # or the Artistic License (the same terms as Perl itself) # -# (C) Paul Evans, 2008,2009 -- leonerd@leonerd.org.uk +# (C) Paul Evans, 2008-2011 -- leonerd@leonerd.org.uk package IPC::PerlSSH::Library::FS; @@ -55,8 +55,18 @@ chown chmod lstat mkdir readlink rename rmdir stat symlink unlink utime +The following functions are imported from L<File::Path> with the following +API adjustments: + + mkpath( $path, %opts ) # %opts supports mode, user, group + rmtree( $path, %opts ) # %opts supports safe, keep_root + =cut +init q{ + use File::Path qw( mkpath rmtree ); +}; + func chown => q{my $uid = shift; my $gid = shift; chown $uid, $gid, $_ or die "Cannot chown($uid, $gid, '$_') - $!" for @_;}; @@ -71,6 +81,10 @@ func mkdir => q{mkdir $_[0] or die "Cannot mkdir('$_[0]') - $!"}; +func mkpath => + q{my ( $path, %opts ) = @_; + mkpath $path, \%opts or die "Cannot mkpath('$path') - $!"}; + func readlink => q{my $l = readlink $_[0]; defined $l or die "Cannot readlink('$_[0]') - $!"; $l}; @@ -80,6 +94,10 @@ func rmdir => q{rmdir $_[0] or die "Cannot rmdir('$_[0]') - $!"}; +func rmtree => + q{my ( $path, %opts ) = @_; + rmtree $path, \%opts or die "Cannot rmtree('$_[0]') - $!"}; + func stat => q{my @s = stat $_[0]; @s or die "Cannot stat('$_[0]') - $!"; @s}; === modified file 't/20library-FS.t' --- t/20library-FS.t 2008-07-14 17:31:28 +0000 +++ t/20library-FS.t 2011-02-23 00:46:55 +0000 @@ -2,7 +2,7 @@ use strict; -use Test::More tests => 15; +use Test::More tests => 17; use File::Temp qw( tempdir ); use IPC::PerlSSH; @@ -68,3 +68,9 @@ $ips->call( "rmdir", "$dir/dir" ); ok( !-d "$dir/dir", 'remote rmdir' ); + +$ips->call( "mkpath", "$dir/a/b/c" ); +ok( -d "$dir/a/b/c", 'remote mkpath' ); + +$ips->call( "rmtree", "$dir/a" ); +ok( !-d "$dir/a", 'remote rmtree' );


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.