line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2011-2015 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.01. |
5
|
5
|
|
|
5
|
|
42203
|
use warnings; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
141
|
|
6
|
5
|
|
|
5
|
|
18
|
use strict; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
168
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package POSIX::1003::FS; |
9
|
5
|
|
|
5
|
|
17
|
use vars '$VERSION'; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
272
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.99_07'; |
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
17
|
use base 'POSIX::1003::Module'; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
1467
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my (@constants, @access, @stat, @glob); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# POSIX.xs defines L_ctermid L_cuserid L_tmpname: useless! |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my @functions = qw/ |
19
|
|
|
|
|
|
|
mkfifo mknod stat lstat rename |
20
|
|
|
|
|
|
|
access lchown |
21
|
|
|
|
|
|
|
utime |
22
|
|
|
|
|
|
|
major minor makedev |
23
|
|
|
|
|
|
|
/; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @IN_CORE = qw(utime mkdir stat lstat rename); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our %EXPORT_TAGS = |
28
|
|
|
|
|
|
|
( constants => \@constants |
29
|
|
|
|
|
|
|
, functions => \@functions |
30
|
|
|
|
|
|
|
, access => \@access |
31
|
|
|
|
|
|
|
, stat => \@stat |
32
|
|
|
|
|
|
|
, glob => \@glob |
33
|
|
|
|
|
|
|
, tables => [ qw/%access %stat/ ] |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my ($fsys, %access, %stat, %glob); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
BEGIN |
39
|
5
|
|
|
5
|
|
814
|
{ $fsys = fsys_table; |
40
|
5
|
|
|
|
|
58
|
push @constants, keys %$fsys; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# initialize the :access export tag |
43
|
5
|
|
|
|
|
14
|
@access = qw/access/; |
44
|
5
|
|
|
|
|
174
|
push @access, grep /_OK$|MAX/, keys %$fsys; |
45
|
5
|
|
|
|
|
13
|
my %access_subset; |
46
|
5
|
|
|
|
|
6
|
@access_subset{@access} = @{$fsys}{@access}; |
|
5
|
|
|
|
|
24
|
|
47
|
5
|
|
|
|
|
29
|
tie %access, 'POSIX::1003::ReadOnlyTable', \%access_subset; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# initialize the :stat export tag |
50
|
5
|
|
|
|
|
13
|
@stat = qw/stat lstat mkfifo mknod mkdir lchown |
51
|
|
|
|
|
|
|
S_ISDIR S_ISCHR S_ISBLK S_ISREG S_ISFIFO S_ISLNK S_ISSOCK S_ISWHT |
52
|
|
|
|
|
|
|
/; |
53
|
5
|
|
|
|
|
109
|
push @stat, grep /^S_I/, keys %$fsys; |
54
|
5
|
|
|
|
|
14
|
my %stat_subset; |
55
|
5
|
|
|
|
|
6
|
@stat_subset{@stat} = @{$fsys}{@stat}; |
|
5
|
|
|
|
|
53
|
|
56
|
5
|
|
|
|
|
20
|
tie %stat, 'POSIX::1003::ReadOnlyTable', \%stat_subset; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# initialize the :fsys export tag |
59
|
5
|
|
|
|
|
9
|
@glob = qw/posix_glob fnmatch/; |
60
|
5
|
|
|
|
|
166
|
push @glob, grep /^(?:GLOB|FNM|WRDE)_/, keys %$fsys; |
61
|
5
|
|
|
|
|
79
|
my %glob_subset; |
62
|
5
|
|
|
|
|
8
|
@glob_subset{@glob} = @{$fsys}{@glob}; |
|
5
|
|
|
|
|
42
|
|
63
|
5
|
|
|
|
|
19
|
tie %glob, 'POSIX::1003::ReadOnlyTable', \%glob_subset; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
1
|
0
|
sub S_ISDIR($) { ($_[0] & S_IFMT()) == S_IFDIR()} |
68
|
0
|
|
|
0
|
1
|
0
|
sub S_ISCHR($) { ($_[0] & S_IFMT()) == S_IFCHR()} |
69
|
0
|
|
|
0
|
1
|
0
|
sub S_ISBLK($) { ($_[0] & S_IFMT()) == S_IFBLK()} |
70
|
0
|
|
|
0
|
1
|
0
|
sub S_ISREG($) { ($_[0] & S_IFMT()) == S_IFREG()} |
71
|
0
|
|
|
0
|
1
|
0
|
sub S_ISFIFO($) { ($_[0] & S_IFMT()) == S_IFIFO()} |
72
|
0
|
|
|
0
|
1
|
0
|
sub S_ISLNK($) { ($_[0] & S_IFMT()) == S_IFLNK()} |
73
|
0
|
|
|
0
|
1
|
0
|
sub S_ISSOCK($) { ($_[0] & S_IFMT()) == S_IFSOCK()} |
74
|
0
|
|
|
0
|
1
|
0
|
sub S_ISWHT($) { ($_[0] & S_IFMT()) == S_IFWHT()} # FreeBSD |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub lchown($$@) |
78
|
0
|
|
|
0
|
1
|
0
|
{ my ($uid, $gid) = (shift, shift); |
79
|
0
|
|
|
|
|
0
|
my $successes = 0; |
80
|
0
|
|
0
|
|
|
0
|
POSIX::lchown($uid, $gid, $_) && $successes++ for @_; |
81
|
0
|
|
|
|
|
0
|
$successes; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub posix_glob($%) |
86
|
5
|
|
|
5
|
0
|
2860
|
{ my ($patterns, %args) = @_; |
87
|
5
|
|
66
|
|
|
30
|
my $flags = $args{flags} |
88
|
|
|
|
|
|
|
// $glob{GLOB_NOSORT}|$glob{GLOB_NOESCAPE}|$glob{GLOB_BRACE}; |
89
|
5
|
|
100
|
0
|
|
29
|
my $errfun = $args{on_error} || sub {0}; |
|
0
|
|
|
|
|
0
|
|
90
|
|
|
|
|
|
|
|
91
|
5
|
|
|
|
|
6
|
my ($err, @fns); |
92
|
5
|
50
|
|
|
|
7
|
if(ref $patterns eq 'ARRAY') |
93
|
0
|
|
|
|
|
0
|
{ foreach my $pattern (@$patterns) |
94
|
0
|
|
|
|
|
0
|
{ my $thiserr = _glob(@fns, $pattern, $flags, $errfun); |
95
|
0
|
0
|
0
|
|
|
0
|
next if !$thiserr || $thiserr==$glob{GLOB_NOMATCH}; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
0
|
$err = $thiserr; |
98
|
0
|
|
|
|
|
0
|
last; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
else |
102
|
5
|
|
|
|
|
348
|
{ $err = _glob(@fns, $patterns, $flags, $errfun); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
5
|
50
|
33
|
|
|
13
|
if($args{unique} && @fns) |
106
|
0
|
|
|
|
|
0
|
{ my %seen; |
107
|
0
|
|
|
|
|
0
|
@fns = grep !$seen{$_}++, @fns; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
5
|
0
|
33
|
|
|
10
|
$err //= @fns ? $glob{GLOB_NOMATCH} : 0; |
111
|
5
|
|
|
|
|
21
|
($err, \@fns); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub fnmatch($$;$) |
116
|
2
|
|
|
2
|
1
|
145
|
{ my ($pat, $name, $flags) = @_; |
117
|
2
|
|
50
|
|
|
35
|
_fnmatch($pat, $name, $flags//0); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
#--------- |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub _create_constant($) |
123
|
84
|
|
|
84
|
|
66
|
{ my ($class, $name) = @_; |
124
|
84
|
|
|
|
|
73
|
my $val = $fsys->{$name}; |
125
|
84
|
|
|
0
|
|
395
|
sub() {$val}; |
|
0
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |