| 1 | #! perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 106 | ▶ | use v5.26; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 106 | ▶ | use feature qw( signatures ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 106 | ▶ | no warnings qw( experimental::signatures ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 106 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | package ChordPro::Files; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Generalize some file system operations so they use LongPath on Windows. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # This is necessary for long filenames and unicode filenames. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # NOTE: FILENAMES SHOULD AT ALL TIMES BE PERL STRINGS! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # Where do filenames come from? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # 1. Command line arguments. Decode ASAP. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # 2. File (and directory) dialogs: Always perl string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # 3. Preferences, configs, recents: should all be perl strings. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # 4. From filelists. We expect these lists to have UTF8 filenames that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # get decoded when the list is read. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 106 | ▶ | use Encode qw( decode_utf8 encode_utf8 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 106 | ▶ | use Ref::Util qw(is_ref); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 106 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 106 | our @EXPORT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 106 | our @EXPORT_OK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ################ Platforms ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 106 | ▶ | use constant MSWIN => $^O =~ /MSWin|Windows_NT/i ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 3687 | ▶ | sub is_msw () { MSWIN } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_msw: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | ▶ | sub is_macos () { $^O =~ /darwin/ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_macos: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub is_wx () { defined($Wx::wxVERSION) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_wx: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 106 | push( @EXPORT, qw( is_msw is_macos is_wx ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 106 | ▶ | if ( is_msw ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | require Win32::LongPath; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ################ ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # General pattern: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # If Windows, call Windows specific function. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # Otherwise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # If the filename contains UTF8 characters, encode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # Call standard perl function. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 520 | ▶ | sub fs_open( $name, $mode = '<:utf8' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fs_open: called CC=6 SCAR=20.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 520 | my $fd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 520 | ▶ | if ( is_msw ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | Win32::LongPath::openL( \$fd, $mode, $name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | or die("$name: $^E\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | return $fd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 520 | my $uname = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 520 | ▶ | $uname = encode_utf8($name) if utf8::is_utf8($uname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 520 | ▶ | open( $fd, $mode, $uname ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | or die("$name: $!\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 520 | return $fd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 106 | push( @EXPORT, qw(fs_open) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1813 | ▶ | sub fs_test( $tests, $name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fs_test: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1813 | my $res = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1813 | for my $test ( split( //, $tests ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2929 | $res = _fs_test( $test, $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 2929 | ▶ | return unless $res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1325 | $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2929 | ▶ | sub _fs_test( $test, $name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fs_test: called CC=19 SCAR=44.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2929 | ▶ | return Win32::LongPath::testL( $test, $name ) if is_msw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2929 | my $uname = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2929 | ▶ | $uname = encode_utf8($name) if utf8::is_utf8($uname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if ( $test eq 'b' ) { return -b $uname } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 16 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | elsif ( $test eq 'c' ) { return -c $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 270 | elsif ( $test eq 'd' ) { return -d $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | elsif ( $test eq 'e' ) { return -e $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1318 | elsif ( $test eq 'f' ) { return -f $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | elsif ( $test eq 'l' ) { return -l $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | elsif ( $test eq 'o' ) { return -o $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | elsif ( $test eq 'O' ) { return -O $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 6 | elsif ( $test eq 'r' ) { return -r $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | elsif ( $test eq 'R' ) { return -R $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1335 | elsif ( $test eq 's' ) { return -s $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | elsif ( $test eq 'w' ) { return -w $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | elsif ( $test eq 'W' ) { return -W $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | elsif ( $test eq 'x' ) { return -x $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | elsif ( $test eq 'X' ) { return -X $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | elsif ( $test eq 'z' ) { return -z $uname } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | else { die("Invalid test '$test' for $name\n") } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 106 | push( @EXPORT, qw(fs_test) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 3 | ▶ | sub fs_unlink( $name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fs_unlink: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 3 | ▶ | return Win32::LongPath::unlinkL($name) if is_msw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 3 | my $uname = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | ▶ | $uname = encode_utf8($name) if utf8::is_utf8($uname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 3 | unlink($uname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 106 | push( @EXPORT, qw(fs_unlink) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | sub fs_find( $folder, $opts = {} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fs_find: called CC=6 SCAR=25.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | my $filter = $opts->{filter} // qr/[.]/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{"filter"} // qr/[.]/iu
MC/DC0%0/1
$opts->{"filter"} // qr/[.]/iu
$opts->{"filter"}
Truth table50%1/2
A
A= $opts->{"filter"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | ▶ | my $recurse = $opts->{recurse} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{"recurse"} // 1
MC/DC0%0/1
$opts->{"recurse"} // 1
$opts->{"recurse"}
Truth table50%1/2
A
A= $opts->{"recurse"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | $opts->{subfolders} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | unless ( is_msw ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | my $ufolder = $folder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | ▶ | $ufolder = encode_utf8($folder) if utf8::is_utf8($folder); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 106 | ▶ | use File::Find qw(find); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | my @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 271 | ▶ | find sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 271 | ▶ | if ( -d && $File::Find::name ne $folder ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
-d $_ and $File::Find::name ne $folder
MC/DC100%2/2
-d $_ and $File::Find::name ne $folder
-d $_
$File::Find::name ne $folder
Truth table100%3/3
A and B
A= -d $_B= $File::Find::name ne $folder
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 8 | $File::Find::prune = !$recurse; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 8 | $opts->{subfolders} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | ▶ | elsif ( -s _ && $_ =~ $filter ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
-s _ and $_ =~ /$filter/u
MC/DC50%1/2
-s _ and $_ =~ /$filter/u
-s _
$_ =~ /$filter/u
Truth table66%2/3
A and B
A= -s _B= $_ =~ /$filter/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 3 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | my @st = stat(_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | push( @files, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | { name => decode_utf8($File::Find::name =~ s;^\Q$ufolder\E/?;;r), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 3 | map { $_ => $st[$i++] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | qw{ dev ino mode nlink uid gid rdev size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | atime mtime ctime blksize blocks } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | }, $ufolder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | @files = sort { $a->{name} cmp $b->{name} } @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | return \@files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub search_tree( $path, $opts, $folder ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_tree: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | my $filter = $opts->{filter} // qr/[.]/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts->{"filter"} // qr/[.]/iu
MC/DC0%0/1
$opts->{"filter"} // qr/[.]/iu
$opts->{"filter"}
Truth table0%0/2
A
A= $opts->{"filter"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | my $recurse = $opts->{recurse} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts->{"recurse"} // 1
MC/DC0%0/1
$opts->{"recurse"} // 1
$opts->{"recurse"}
Truth table0%0/2
A
A= $opts->{"recurse"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $dir = Win32::LongPath->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | $dir->opendirL($path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | or die ("$path: $^E\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | foreach my $file ( $dir->readdirL ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # Skip parent dir. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | next if $file eq '..'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # Get file stats. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | my $name = $file eq '.' ? $path : "$path/$file"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | my $stat = Win32::LongPath::lstatL($name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | or die( "stat($name,", Win32::LongPath::getcwdL(), "): $^E\n" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # Recurse if dir. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | if ( ( $file ne '.' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$file ne "." and ($stat->{"attribs"} & (Win32::LongPath::FILE_ATTRIBUTE_DIRECTORY() | Win32::LongPath::FILE_ATTRIBUTE_REPARSE_POINT())) == Win32::LongPath::FILE_ATTRIBUTE_DIRECTORY()
MC/DC0%0/2
$file ne "." and ($stat->{"attribs"} & (Win32::LongPath::FILE_ATTRIBUTE_DIRECTORY() | Win32::LongPath::FILE_ATTRIBUTE_REPARSE_POINT())) == Win32::LongPath::FILE_ATTRIBUTE_DIRECTORY()
$file ne "."
($stat->{"attribs"} & (Win32::LongPath::FILE_ATTRIBUTE_DIRECTORY() | Win32::LongPath::FILE_ATTRIBUTE_REPARSE_POINT())) == Win32::LongPath::FILE_ATTRIBUTE_DIRECTORY()
Truth table0%0/3
A and B
A= $file ne "."B= ($stat->{"attribs"} & (Win32::LongPath::FILE_ATTRIBUTE_DIRECTORY() | Win32::LongPath::FILE_ATTRIBUTE_REPARSE_POINT())) == Win32::LongPath::FILE_ATTRIBUTE_DIRECTORY()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | && ( ($stat->{attribs} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | & ( Win32::LongPath::FILE_ATTRIBUTE_DIRECTORY() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | | Win32::LongPath::FILE_ATTRIBUTE_REPARSE_POINT() ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | == Win32::LongPath::FILE_ATTRIBUTE_DIRECTORY() ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | push( @files, @{ search_tree( $name, $opts, $folder ) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | if $recurse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $opts->{subfolders} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $name =~ s;^\Q$folder\E/?;;; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | push( @files, { #%$stat, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | full => Win32::LongPath::abspathL($name) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | if $file =~ $filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $dir->closedirL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | return \@files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | return [ sort { $a->{name} cmp $b->{name} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | @{ search_tree( $folder, $opts, $folder ) } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 106 | push( @EXPORT, qw(fs_find) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub fs_copy( $from, $to ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fs_copy: not called CC=4 SCAR=24.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | return Win32::LongPath::copyL( $from, $to ) if is_msw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | $to = encode_utf8($to) if utf8::is_utf8($to); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | $from = encode_utf8($from) if utf8::is_utf8($from); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 106 | ▶ | use File::Copy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | copy( $from, $to ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 106 | push( @EXPORT, qw(fs_copy) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # Wrapper for File::LoadLines. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 499 | ▶ | sub fs_load( $name, $opts = {} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fs_load: called CC=9 SCAR=25.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 106 | ▶ | use File::LoadLines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 499 | ▶ | $opts->{fail} //= "soft"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts->{"fail"} //= "soft"
MC/DC100%1/1
$opts->{"fail"} //= "soft"
$opts->{"fail"}
Truth table100%2/2
A
A= $opts->{"fail"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 499 | my $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 499 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 499 | ▶ | if ( is_ref($name) || $name =~ m;^\w\w+:; ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
is_ref($name) or $name =~ /^\w\w+:/u
MC/DC50%1/2
is_ref($name) or $name =~ /^\w\w+:/u
is_ref($name)
$name =~ /^\w\w+:/u
Truth table66%2/3
A or B
A= is_ref($name)B= $name =~ /^\w\w+:/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 82 | $ret = loadlines( $name, $opts ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 417 | ▶ | my $fd = $name eq '-' ? \*STDIN : fs_open($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 417 | $ret = loadlines( $fd, $opts ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 417 | $opts->{_filesource} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 499 | ▶ | return $ret unless $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $msg = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | die( "$msg\n" ) unless $opts->{fail} eq "soft"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | $msg = $1 if $msg =~ /^\Q$name\E: (.*)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $opts->{error} = $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | sub fs_blob( $name, $opts = {} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fs_blob: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | fs_load( $name, { blob => 1, %$opts } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 106 | push( @EXPORT, qw(fs_load fs_blob) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | ################ File::Spec functions ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | # Adapted from File::Spec::Functions 3.75. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # Function fn_catfile = File::Spec->catfile, etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 106 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 106 | require File::Spec::Unix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 106 | my @funcs = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | qw( canonpath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | catdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | catfile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | curdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | rootdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | updir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | is_absolute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | splitpath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | catpath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | devnull | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | tmpdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | splitdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | abs2rel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | rel2abs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | case_tolerant | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 106 | push( @EXPORT, map { "fn_$_" } @funcs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 106 | my %udeps = ( canonpath => [], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | catdir => [ qw(canonpath) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | catfile => [ qw(canonpath catdir) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | case_tolerant => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | curdir => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | devnull => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | rootdir => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | updir => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 106 | foreach my $meth ( @funcs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 1696 | ▶ | $meth = 'file_name_is_absolute' if $meth eq 'is_absolute'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 1696 | my $sub = File::Spec->can($meth); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 106 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 1696 | ▶ | if ( exists( $udeps{$meth} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
exists $udeps{$meth} and $sub == "File::Spec::Unix"->can($meth) and not grep({"File::Spec"->can($_) != "File::Spec::Unix"->can($_);} @{$udeps{$meth};}) and defined &{"File::Spec::Unix::_fn_$meth";}
exists $udeps{$meth} and $sub == "File::Spec::Unix"->can($meth) and not grep({"File::Spec"->can($_) != "File::Spec::Unix"->can($_);} @{$udeps{$meth};})
exists $udeps{$meth} and $sub == "File::Spec::Unix"->can($meth)
MC/DC25%1/4
exists $udeps{$meth} and $sub == "File::Spec::Unix"->can($meth) and not grep({"File::Spec"->can($_) != "File::Spec::Unix"->can($_);} @{$udeps{$meth};}) and defined &{"File::Spec::Unix::_fn_$meth";}
exists $udeps{$meth}
$sub == "File::Spec::Unix"->can($meth)
not grep({"File::Spec"->can($_) != "File::Spec::Unix"->can($_);} @{$udeps{$meth};})
defined &{"File::Spec::Unix::_fn_$meth";}
Truth table40%2/5
A and B and not(C) and D
A= exists $udeps{$meth}B= $sub == "File::Spec::Unix"->can($meth)C= not grep({"File::Spec"->can($_) != "File::Spec::Unix"->can($_);} @{$udeps{$meth};})D= defined &{"File::Spec::Unix::_fn_$meth";}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | && $sub == File::Spec::Unix->can($meth) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 318 | && !( grep { File::Spec->can($_) != File::Spec::Unix->can($_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 848 | @{$udeps{$meth} } ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 848 | && defined( &{"File::Spec::Unix::_fn_$meth"} ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 848 | *{"fn_$meth"} = \&{"File::Spec::Unix::_fn_$meth"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 848 | ▶ | $meth = 'is_absolute' if $meth eq 'file_name_is_absolute'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 335 | ▶ | *{"fn_$meth"} = sub { &$sub( 'File::Spec', @_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | ################ File::Basename functions ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # For now, use File:Basename functions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # Refine to File::Spec functions later. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 106 | ▶ | use File::Basename (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | sub fn_basename( $fullname, @suffixlist ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fn_basename: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | File::Basename::basename( $fullname, @suffixlist ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 106 | push( @EXPORT, "fn_basename" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | sub fn_dirname( $fullname ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fn_dirname: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | File::Basename::dirname( $fullname ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 106 | push( @EXPORT, "fn_dirname" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 106 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||