Codebase list libfile-path-tiny-perl / 8a523bf
Imported Upstream version 0.3 Alessandro Ghedini 12 years ago
6 changed file(s) with 36 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
00 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()
15
26 0.2 Sun Mar 11 16:50:44 2012
37 rt 51728 Missing colon in synopsis
00 --- #YAML:1.0
11 name: File-Path-Tiny
2 version: 0.2
2 version: 0.3
33 abstract: recursive versions of mkdir() and rmdir() without as much overhead as File::Path
44 author:
55 - Daniel Muey <http://drmuey.com/cpan_contact.pl>
6 license: unknown
6 license: perl
77 distribution_type: module
88 configure_requires:
99 ExtUtils::MakeMaker: 0
77 VERSION_FROM => 'lib/File/Path/Tiny.pm',
88 ABSTRACT_FROM => 'lib/File/Path/Tiny.pod',
99 PL_FILES => {},
10 LICENSE => 'perl',
1011 PREREQ_PM => {
1112 'Test::More' => 0,
1213 },
0 File-Path-Tiny version 0.1
0 File-Path-Tiny version 0.3
11
22 DOCUMENTATION
33
00 package File::Path::Tiny;
11
2 $File::Path::Tiny::VERSION = 0.2;
2 $File::Path::Tiny::VERSION = 0.3;
33
44 sub mk {
55 my ( $path, $mask ) = @_;
2929 my ($path) = @_;
3030 if ( -e $path && !-d $path ) { $! = 20; return; }
3131 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;
4533 rmdir($path) or return;
4634 return 1;
4735 }
4836
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
4956 1;
33
44 =head1 VERSION
55
6 This document describes File::Path::Tiny version 0.2
6 This document describes File::Path::Tiny version 0.3
77
88 =head1 SYNOPSIS
99
7878 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.
7979
8080 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.
8187
8288 =head1 DIAGNOSTICS
8389