blib/lib/File/Path/Stderr.pm

filter: Statementstmt 48.2% 14 / 29 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 30.0% 3 / 10 Podpod 100% 4 / 4 totaltotal 48.8% 21 / 43 CC 1 SCAR 5.3
CC
1
Cov
48%
DESTORY
2.0
_with_stdderr
2.0
__ANON__
2.0
CRAP 1.7
↑ Summary
1 package File::Path::Stderr;
2  
3 2 ▶use 5.005; # yes, really
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 #use warnings;
7  
8 2 ▶use File::Path ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 require Exporter;
11 2 @File::Path::Stderr::ISA = qw(Exporter);
12 2 @File::Path::Stderr::EXPORT = qw(mkpath rmpath);
13 2 @File::Path::Stderr::EXPORT_OK = qw(make_path remove_tree);
14 2 $File::Path::Stderr::VERSION = "2.00";
15  
16 =head1 NAME
17  
18 File::Path::Stderr - like File::Path but print to STDERR
19  
20 =head1 SYNOPSIS
21  
22 use File::Path::Stderr qw(make_path remove_tree);
23  
24 make_path('foo/bar/baz', '/zug/zwang');
25 make_path('foo/bar/baz', '/zug/zwang', {
26 verbose => 1,
27 mode => 0711,
28 });
29  
30 remove_tree('foo/bar/baz', '/zug/zwang');
31 remove_tree('foo/bar/baz', '/zug/zwang', {
32 verbose => 1,
33 error => \my $err_list,
34 });
35  
36 # legacy (interface promoted before v2.00)
37 mkpath('/foo/bar/baz');
38 mkpath('/foo/bar/baz', 1, 0711);
39 mkpath(['/foo/bar/baz', 'blurfl/quux'], 1, 0711);
40 rmtree('foo/bar/baz', 1, 1);
41 rmtree(['foo/bar/baz', 'blurfl/quux'], 1, 1);
42  
43 # legacy (interface promoted before v2.06)
44 mkpath('foo/bar/baz', '/zug/zwang', { verbose => 1, mode => 0711 });
45 rmtree('foo/bar/baz', '/zug/zwang', { verbose => 1, mode => 0711 });
46  
47 =head1 DESCRIPTION
48  
49 This is a very, very simple wrapper around B<File::Path>. All
50 exported functions function exactly the same as they do in B<File::Path>
51 except rather than printing activity reports to the currently selected
52 filehandle (which is normally STDOUT) the messages about what B<File::Path>
53 is doing are printed to STDERR.
54  
55 =head2 Functions
56  
57 The following functions from File::Path are currently supported:
58  
59 =over
60  
61 =item mkpath
62  
63 =item rmpath
64  
65 =item make_path
66  
67 =item remove_tree
68  
69 =back
70  
71 By default, if you don't request a particular import list,
72 C<mkpath> and C<rmpath> will be exported by default.
73  
74 =cut
75  
76 0 ▶sub File::Path::Stderr::End::DESTORY {
Subroutine DESTORY: not called CC=1 SCAR=6.9
77 0 my $self = shift;
78 0 return $self->();
79 }
80  
81 0 ▶sub _with_stdderr(&) {
Subroutine _with_stdderr: not called CC=1 SCAR=6.9
82 # remember what file handle was selected
83 0 my $old = select();
84  
85 # select STDERR instead
86 0 select(STDERR);
87  
88 # after we've returned (but before the next statement)
89 # switch the file handle back to what it was before
90 0 ▶ my $run_on_destroy = bless sub { select($old) }, "File::Path::Stderr::End";
Subroutine __ANON__: not called CC=1 SCAR=6.9
91  
92 # run the passed codeblock
93 0 return $_[0]->();
94 }
95  
96 0 ▶sub mkpath { return _with_stderr { File::Path::mkpath(@_); } }
Subroutine mkpath: not called CC=1 SCAR=6.9
Pod documented
97 0 ▶sub rmpath { return _with_stderr { File::Path::rmpath(@_); } }
Subroutine rmpath: not called CC=1 SCAR=6.9
Pod documented
98 0 ▶sub make_path { return _with_stderr { File::Path::make_path(@_); } }
Subroutine make_path: not called CC=1 SCAR=6.9
Pod documented
99 0 ▶sub remove_tree { return _with_stderr { File::Path::remove_tree(@_); } }
Subroutine remove_tree: not called CC=1 SCAR=6.9
Pod documented
100  
101 =head1 AUTHOR
102  
103 Written by Mark Fowler E<lt>mark@twoshortplanks.comE<gt>
104  
105 Copryright Mark Fowler 2003, 2012. All Rights Reserved.
106  
107 Most of the SYNOPSIS stolen directly from File::Path.
108 File::Path copyright (C) Charles Bailey, Tim Bunce and David
109 Landgren 1995-2009. All rights reserved.
110  
111 This program is free software; you can redistribute it
112 and/or modify it under the same terms as Perl itself.
113  
114 =head1 BUGS
115  
116 None known.
117  
118 Bugs should be reported to me via the CPAN RT system.
119 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File::Path::Stderr>.
120  
121 Alternatively, you can simply fork this project on github and
122 send me pull requests. Please see
123 L<http://github.com/2shortplanks/File-Path-Stderr>
124  
125 =head1 SEE ALSO
126  
127 L<File::Path>
128  
129 =cut
130  
131 2 1;
↑ Summary