Imported Upstream version 0.3
Alessandro Ghedini
12 years ago
0 | 0 |
Revision history for File-Path-Tiny
|
|
1 |
|
|
2 |
0.3 Fri Apr 6 19:39:52 2012
|
|
3 |
rt 76061 No LICENSE in META.yml
|
|
4 |
rt 68950 break out rm() code into empty() type function, use it in rm()
|
1 | 5 |
|
2 | 6 |
0.2 Sun Mar 11 16:50:44 2012
|
3 | 7 |
rt 51728 Missing colon in synopsis
|
0 | 0 |
--- #YAML:1.0
|
1 | 1 |
name: File-Path-Tiny
|
2 | |
version: 0.2
|
|
2 |
version: 0.3
|
3 | 3 |
abstract: recursive versions of mkdir() and rmdir() without as much overhead as File::Path
|
4 | 4 |
author:
|
5 | 5 |
- Daniel Muey <http://drmuey.com/cpan_contact.pl>
|
6 | |
license: unknown
|
|
6 |
license: perl
|
7 | 7 |
distribution_type: module
|
8 | 8 |
configure_requires:
|
9 | 9 |
ExtUtils::MakeMaker: 0
|
7 | 7 |
VERSION_FROM => 'lib/File/Path/Tiny.pm',
|
8 | 8 |
ABSTRACT_FROM => 'lib/File/Path/Tiny.pod',
|
9 | 9 |
PL_FILES => {},
|
|
10 |
LICENSE => 'perl',
|
10 | 11 |
PREREQ_PM => {
|
11 | 12 |
'Test::More' => 0,
|
12 | 13 |
},
|
0 | |
File-Path-Tiny version 0.1
|
|
0 |
File-Path-Tiny version 0.3
|
1 | 1 |
|
2 | 2 |
DOCUMENTATION
|
3 | 3 |
|
0 | 0 |
package File::Path::Tiny;
|
1 | 1 |
|
2 | |
$File::Path::Tiny::VERSION = 0.2;
|
|
2 |
$File::Path::Tiny::VERSION = 0.3;
|
3 | 3 |
|
4 | 4 |
sub mk {
|
5 | 5 |
my ( $path, $mask ) = @_;
|
|
29 | 29 |
my ($path) = @_;
|
30 | 30 |
if ( -e $path && !-d $path ) { $! = 20; return; }
|
31 | 31 |
return 2 if !-d $path;
|
32 | |
opendir( DIR, $path ) or return;
|
33 | |
my @contents = grep { $_ ne '.' && $_ ne '..' } readdir(DIR);
|
34 | |
closedir DIR;
|
35 | |
require File::Spec if @contents;
|
36 | |
for my $thing (@contents) {
|
37 | |
my $long = File::Spec->catdir( $path, $thing );
|
38 | |
if ( !-l $long && -d $long ) {
|
39 | |
rm($long) or return;
|
40 | |
}
|
41 | |
else {
|
42 | |
unlink $long or return;
|
43 | |
}
|
44 | |
}
|
|
32 |
empty_dir($path) or return;
|
45 | 33 |
rmdir($path) or return;
|
46 | 34 |
return 1;
|
47 | 35 |
}
|
48 | 36 |
|
|
37 |
sub empty_dir {
|
|
38 |
my ($path) = @_;
|
|
39 |
if ( -e $path && !-d $path ) { $! = 20; return; }
|
|
40 |
opendir( DIR, $path ) or return;
|
|
41 |
my @contents = grep { $_ ne '.' && $_ ne '..' } readdir(DIR);
|
|
42 |
closedir DIR;
|
|
43 |
require File::Spec if @contents;
|
|
44 |
for my $thing (@contents) {
|
|
45 |
my $long = File::Spec->catdir( $path, $thing );
|
|
46 |
if ( !-l $long && -d $long ) {
|
|
47 |
rm($long) or return;
|
|
48 |
}
|
|
49 |
else {
|
|
50 |
unlink $long or return;
|
|
51 |
}
|
|
52 |
}
|
|
53 |
return 1;
|
|
54 |
}
|
|
55 |
|
49 | 56 |
1;
|
3 | 3 |
|
4 | 4 |
=head1 VERSION
|
5 | 5 |
|
6 | |
This document describes File::Path::Tiny version 0.2
|
|
6 |
This document describes File::Path::Tiny version 0.3
|
7 | 7 |
|
8 | 8 |
=head1 SYNOPSIS
|
9 | 9 |
|
|
78 | 78 |
It is recursive in the sense that given /foo/bar/baz as the path to remove it will recursively empty 'baz' and then remove it from /foo/bar.
|
79 | 79 |
|
80 | 80 |
Its parents, /, /foo, and /foo/bar are *not* touched.
|
|
81 |
|
|
82 |
=head2 File::Path::Tiny::empty_dir()
|
|
83 |
|
|
84 |
Takes a single path to recursively empty but not remove.
|
|
85 |
|
|
86 |
Returns false when there is a problem.
|
81 | 87 |
|
82 | 88 |
=head1 DIAGNOSTICS
|
83 | 89 |
|