blib/lib/POSIX/1003/FS.pm

filter: Statementstmt 71.6% 53 / 74 Branchbran 20.0% 2 / 10 Conditioncond 43.7% 7 / 16 MC/DCmcdc 10.0% 1 / 10 Subroutinesub 42.1% 8 / 19 Podpod 90.9% 10 / 11 totaltotal 57.8% 81 / 140 CC 14 SCAR 25.8
CC
14
Cov
62%
posix_glob
32.7
lchown
12.0
fnmatch
2.1
CRAP 13.3
« blib/lib/POSIX/1003/Time.pm ↑ Summary blib/lib/POSIX/1003/Pathconf.pm »
1 # Copyrights 2011-2020 by [Mark Overmeer].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.02.
5 # This code is part of distribution POSIX-1003. Meta-POD processed with
6 # OODoc into POD and HTML manual-pages. See README.md
7 # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8  
9 package POSIX::1003::FS;
10 7 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 $VERSION = '1.02';
12  
13 7 ▶use base 'POSIX::1003::Module';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 7 my (@constants, @access, @stat, @glob);
19  
20 # POSIX.xs defines L_ctermid L_cuserid L_tmpname: useless!
21  
22 7 my @functions = qw/
23 mkfifo mknod stat lstat rename
24 access lchown
25 utime
26 major minor makedev
27 /;
28  
29 7 our @IN_CORE = qw(utime mkdir stat lstat rename);
30  
31 7 our %EXPORT_TAGS =
32 ( constants => \@constants
33 , functions => \@functions
34 , access => \@access
35 , stat => \@stat
36 , glob => \@glob
37 , tables => [ qw/%access %stat/ ]
38 );
39  
40 7 my ($fsys, %access, %stat, %glob);
41  
42 BEGIN
43 7 ▶ { $fsys = fsys_table;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 7 push @constants, keys %$fsys;
45  
46 # initialize the :access export tag
47 7 @access = qw/access/;
48 7 push @access, grep /_OK$|MAX/, keys %$fsys;
49 7 my %access_subset;
50 7 @access_subset{@access} = @{$fsys}{@access};
51 7 tie %access, 'POSIX::1003::ReadOnlyTable', \%access_subset;
52  
53 # initialize the :stat export tag
54 7 @stat = qw/stat lstat mkfifo mknod mkdir lchown
55 S_ISDIR S_ISCHR S_ISBLK S_ISREG S_ISFIFO S_ISLNK S_ISSOCK S_ISWHT
56 /;
57 7 push @stat, grep /^S_I/, keys %$fsys;
58 7 my %stat_subset;
59 7 @stat_subset{@stat} = @{$fsys}{@stat};
60 7 tie %stat, 'POSIX::1003::ReadOnlyTable', \%stat_subset;
61  
62 # initialize the :fsys export tag
63 7 @glob = qw/posix_glob fnmatch/;
64 7 push @glob, grep /^(?:GLOB|FNM|WRDE)_/, keys %$fsys;
65 7 my %glob_subset;
66 7 @glob_subset{@glob} = @{$fsys}{@glob};
67 7 tie %glob, 'POSIX::1003::ReadOnlyTable', \%glob_subset;
68 }
69  
70  
71 0 ▶sub S_ISDIR($) { ($_[0] & S_IFMT()) == S_IFDIR()}
Subroutine S_ISDIR: not called CC=1 SCAR=6.9
Pod documented
72 0 ▶sub S_ISCHR($) { ($_[0] & S_IFMT()) == S_IFCHR()}
Subroutine S_ISCHR: not called CC=1 SCAR=6.9
Pod documented
73 0 ▶sub S_ISBLK($) { ($_[0] & S_IFMT()) == S_IFBLK()}
Subroutine S_ISBLK: not called CC=1 SCAR=6.9
Pod documented
74 0 ▶sub S_ISREG($) { ($_[0] & S_IFMT()) == S_IFREG()}
Subroutine S_ISREG: not called CC=1 SCAR=6.9
Pod documented
75 0 ▶sub S_ISFIFO($) { ($_[0] & S_IFMT()) == S_IFIFO()}
Subroutine S_ISFIFO: not called CC=1 SCAR=6.9
Pod documented
76 0 ▶sub S_ISLNK($) { ($_[0] & S_IFMT()) == S_IFLNK()}
Subroutine S_ISLNK: not called CC=1 SCAR=6.9
Pod documented
77 0 ▶sub S_ISSOCK($) { ($_[0] & S_IFMT()) == S_IFSOCK()}
Subroutine S_ISSOCK: not called CC=1 SCAR=6.9
Pod documented
78 0 ▶sub S_ISWHT($) { ($_[0] & S_IFMT()) == S_IFWHT()} # FreeBSD
Subroutine S_ISWHT: not called CC=1 SCAR=6.9
Pod documented
79  
80  
81 sub lchown($$@)
82 0 ▶{ my ($uid, $gid) = (shift, shift);
Subroutine lchown: not called CC=3 SCAR=24.8
Pod documented
83 0 my $successes = 0;
84 0 ▶ POSIX::lchown($uid, $gid, $_) && $successes++ for @_;
Branch: 1 branch
BranchTrueFalseTotal
POSIX::lchown($uid, $gid, $_) and ++$successes 0 0 0
85 0 $successes;
86 }
87  
88  
89 sub posix_glob($%)
90 5 ▶{ my ($patterns, %args) = @_;
Subroutine posix_glob: called CC=11 SCAR=34.9
Pod undocumented
91 my $flags = $args{flags}
92 5 ▶ // $glob{GLOB_NOSORT}|$glob{GLOB_NOESCAPE}|$glob{GLOB_BRACE};
Condition100%2/2
$args{"flags"} // $glob{"GLOB_NOSORT"} | $glob{"GLOB_NOESCAPE"} | $glob{"GLOB_BRACE"}
l!l
14
MC/DC100%1/1
$args{"flags"} // $glob{"GLOB_NOSORT"} | $glob{"GLOB_NOESCAPE"} | $glob{"GLOB_BRACE"}
$args{"flags"}
Truth table100%2/2
A
A= $args{"flags"}
Aresult
11
00
93 0 ▶ my $errfun = $args{on_error} || sub {0};
Subroutine __ANON__: not called CC=1 SCAR=0.6
Condition66%2/3
$args{'on_error'} || sub { 0; }
l!l&&r!l&&!r
140
MC/DC0%0/2
$args{'on_error'} || sub { 0; }
$args{'on_error'} sub { 0; }
Truth table66%2/3
A || B
A= $args{'on_error'}B= sub { 0; }
ABresult
1X1
011
000
94  
95 5 my ($err, @fns);
96 5 ▶ if(ref $patterns eq 'ARRAY')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $patterns eq 'ARRAY') { } 0 5 5
97 0 { foreach my $pattern (@$patterns)
98 0 { my $thiserr = _glob(@fns, $pattern, $flags, $errfun);
99 0 ▶ next if !$thiserr || $thiserr==$glob{GLOB_NOMATCH};
Branch: 1 branch
BranchTrueFalseTotal
if not $thiserr or $thiserr == $glob{"GLOB_NOMATCH"} 0 0 0
Condition0%0/3
not $thiserr or $thiserr == $glob{"GLOB_NOMATCH"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not $thiserr or $thiserr == $glob{"GLOB_NOMATCH"}
not $thiserr $thiserr == $glob{"GLOB_NOMATCH"}
Truth table0%0/3
not(A) or B
A= not $thiserrB= $thiserr == $glob{"GLOB_NOMATCH"}
ABresult
1X1
011
000
100  
101 0 $err = $thiserr;
102 0 last;
103 }
104 }
105 else
106 5 { $err = _glob(@fns, $patterns, $flags, $errfun);
107 }
108  
109 5 ▶ if($args{unique} && @fns)
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"unique"} and @fns) 0 5 5
Condition33%1/3
$args{"unique"} and @fns
!ll&&!rl&&r
500
MC/DC0%0/2
$args{"unique"} and @fns
$args{"unique"} @fns
Truth table33%1/3
A and B
A= $args{"unique"}B= @fns
ABresult
0X0
100
111
110 0 { my %seen;
111 0 @fns = grep !$seen{$_}++, @fns;
112 }
113  
114 5 ▶ $err //= @fns ? $glob{GLOB_NOMATCH} : 0;
Branch: 1 branch
BranchTrueFalseTotal
@fns ? : 0 0 0
Condition33%1/3
$err //= @fns ? $glob{"GLOB_NOMATCH"} : 0
l!l&&r!l&&!r
500
MC/DC0%0/2
$err //= @fns ? $glob{"GLOB_NOMATCH"} : 0
$err @fns ? $glob{"GLOB_NOMATCH"} : 0
Truth table33%1/3
A //= B
A= $errB= @fns ? $glob{"GLOB_NOMATCH"} : 0
ABresult
1X1
011
000
115 5 ($err, \@fns);
116 }
117  
118  
119 sub fnmatch($$;$)
120 2 ▶{ my ($pat, $name, $flags) = @_;
Subroutine fnmatch: called CC=2 SCAR=7.2
Pod documented
121 2 ▶ _fnmatch($pat, $name, $flags//0);
Condition50%1/2
$flags // 0
l!l
02
MC/DC0%0/1
$flags // 0
$flags
Truth table50%1/2
A
A= $flags
Aresult
11
00
122 }
123  
124 #---------
125  
126 sub _create_constant($)
127 84 ▶{ my ($class, $name) = @_;
Subroutine _create_constant: called CC=1 SCAR=0.2
128 84 my $val = $fsys->{$name};
129 0 ▶ sub() {$val};
Subroutine __ANON__: not called CC=1 SCAR=1.2
130 }
131  
132 7 1;
« blib/lib/POSIX/1003/Time.pm ↑ Summary blib/lib/POSIX/1003/Pathconf.pm »