.htmlgen/FunctionalPerl/Htmlgen/FileUtil.pm

filter: Statementstmt 73.5% 25 / 34 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 2 totaltotal 60.3% 32 / 53 CC 6 SCAR 21.7
CC
6
Cov
60%
create_parent_dirs
20.0
existingpath_or
12.0
BEGIN
1.0
CRAP 8.8
« lib/Chj/Unix/Signal.pm ↑ Summary lib/FP/PureHash.pm »
1 #
2 # Copyright (c) 2014-2015 Christian Jaeger, copying@christianjaeger.ch
3 #
4 # This is free software, offered under either the same terms as perl 5
5 # or the terms of the Artistic License version 2 or the terms of the
6 # MIT License (Expat version). See the file COPYING.md that came
7 # bundled with this file.
8 #
9  
10 =head1 NAME
11  
12 FunctionalPerl::Htmlgen::FileUtil
13  
14 =head1 SYNOPSIS
15  
16 =head1 DESCRIPTION
17  
18  
19 =head1 NOTE
20  
21 This is alpha software! Read the status section in the package README
22 or on the L<website|http://functional-perl.org/>.
23  
24 =cut
25  
26 package FunctionalPerl::Htmlgen::FileUtil;
27 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 2 ▶use warnings FATAL => 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
30 2 ▶use experimental "signatures";
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 2 ▶use Exporter "import";
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 2 our @EXPORT = qw();
35 2 our @EXPORT_OK = qw(existingpath_or create_parent_dirs);
36 2 our %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]);
37  
38 # lib?
39 0 ▶sub existingpath_or(@paths) {
Subroutine existingpath_or: not called CC=3 SCAR=24.8
Pod undocumented
40 0 for (@paths) {
41 0 ▶ return $_ if -e $_
Branch: 1 branch
BranchTrueFalseTotal
if -e $_ 0 0 0
42 }
43 0 die "none of the paths exist: @paths";
44 }
45  
46 2 ▶use POSIX qw(EEXIST ENOENT);
Subroutine BEGIN: called CC=1 SCAR=0.0
47 2 ▶use Chj::xperlfunc qw(dirname xmkdir);
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 # XX how is this different from xmkdir_p ?
50 0 ▶sub create_parent_dirs ($path0, $path0_to_outpath) {
Subroutine create_parent_dirs: not called CC=4 SCAR=30.0
Pod undocumented
51 0 $path0 = dirname $path0;
52 0 my $outpath = &$path0_to_outpath($path0);
53 0 ▶ if (mkdir $outpath) {
Branch: 3 branches
BranchTrueFalseTotal
if (mkdir $outpath) { } 0 0 0
elsif ($! == 17) { } 0 0 0
elsif ($! == 2) { } 0 0 0
54  
55 # ok, return
56 } elsif ($! == EEXIST) {
57  
58 # ok, return
59 } elsif ($! == ENOENT) {
60 0 create_parent_dirs($path0, $path0_to_outpath);
61 0 xmkdir $outpath;
62 } else {
63 0 die "mkdir '$outpath': $!";
64 }
65 }
66  
67 2 1
« lib/Chj/Unix/Signal.pm ↑ Summary lib/FP/PureHash.pm »