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
|
4
|
|
|
4
|
|
33010
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
158
|
|
6
|
4
|
|
|
4
|
|
15
|
use strict; |
|
4
|
|
|
|
|
2
|
|
|
4
|
|
|
|
|
152
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package POSIX::1003::FS; |
9
|
4
|
|
|
4
|
|
13
|
use vars '$VERSION'; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
267
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.99_06'; |
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
16
|
use base 'POSIX::1003::Module'; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
1826
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Blocks resp from unistd.h, stdio.h, limits.h |
15
|
|
|
|
|
|
|
my @constants; |
16
|
|
|
|
|
|
|
my @access = qw/access/; |
17
|
|
|
|
|
|
|
my @stat = qw/stat lstat mkfifo mknod mkdir lchown |
18
|
|
|
|
|
|
|
S_ISDIR S_ISCHR S_ISBLK S_ISREG S_ISFIFO S_ISLNK S_ISSOCK S_ISWHT |
19
|
|
|
|
|
|
|
/; |
20
|
|
|
|
|
|
|
my @glob = qw/posix_glob/; # fnmatch |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
1
|
0
|
sub S_ISDIR($) { ($_[0] & S_IFMT()) == S_IFDIR()} |
23
|
0
|
|
|
0
|
1
|
0
|
sub S_ISCHR($) { ($_[0] & S_IFMT()) == S_IFCHR()} |
24
|
0
|
|
|
0
|
1
|
0
|
sub S_ISBLK($) { ($_[0] & S_IFMT()) == S_IFBLK()} |
25
|
0
|
|
|
0
|
1
|
0
|
sub S_ISREG($) { ($_[0] & S_IFMT()) == S_IFREG()} |
26
|
0
|
|
|
0
|
1
|
0
|
sub S_ISFIFO($) { ($_[0] & S_IFMT()) == S_IFIFO()} |
27
|
0
|
|
|
0
|
1
|
0
|
sub S_ISLNK($) { ($_[0] & S_IFMT()) == S_IFLNK()} |
28
|
0
|
|
|
0
|
1
|
0
|
sub S_ISSOCK($) { ($_[0] & S_IFMT()) == S_IFSOCK()} |
29
|
0
|
|
|
0
|
1
|
0
|
sub S_ISWHT($) { ($_[0] & S_IFMT()) == S_IFWHT()} # FreeBSD |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# POSIX.xs defines L_ctermid L_cuserid L_tmpname: useless! |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my @functions = qw/ |
34
|
|
|
|
|
|
|
mkfifo mknod stat lstat rename |
35
|
|
|
|
|
|
|
access lchown |
36
|
|
|
|
|
|
|
utime |
37
|
|
|
|
|
|
|
major minor makedev |
38
|
|
|
|
|
|
|
/; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
our @IN_CORE = qw(utime mkdir stat lstat rename); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our %EXPORT_TAGS = |
43
|
|
|
|
|
|
|
( constants => \@constants |
44
|
|
|
|
|
|
|
, functions => \@functions |
45
|
|
|
|
|
|
|
, access => \@access |
46
|
|
|
|
|
|
|
, stat => \@stat |
47
|
|
|
|
|
|
|
, glob => \@glob |
48
|
|
|
|
|
|
|
, tables => [ qw/%access %stat/ ] |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my ($fsys, %access, %stat, %glob); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
BEGIN { |
54
|
4
|
|
|
4
|
|
665
|
$fsys = fsys_table; |
55
|
4
|
|
|
|
|
51
|
push @constants, keys %$fsys; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# initialize the :access export tag |
58
|
4
|
|
|
|
|
135
|
push @access, grep /_OK$|MAX/, keys %$fsys; |
59
|
4
|
|
|
|
|
10
|
my %access_subset; |
60
|
4
|
|
|
|
|
4
|
@access_subset{@access} = @{$fsys}{@access}; |
|
4
|
|
|
|
|
16
|
|
61
|
4
|
|
|
|
|
22
|
tie %access, 'POSIX::1003::ReadOnlyTable', \%access_subset; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# initialize the :stat export tag |
64
|
4
|
|
|
|
|
72
|
push @stat, grep /^S_I/, keys %$fsys; |
65
|
4
|
|
|
|
|
10
|
my %stat_subset; |
66
|
4
|
|
|
|
|
4
|
@stat_subset{@stat} = @{$fsys}{@stat}; |
|
4
|
|
|
|
|
26
|
|
67
|
4
|
|
|
|
|
15
|
tie %stat, 'POSIX::1003::ReadOnlyTable', \%stat_subset; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# initialize the :fsys export tag |
70
|
4
|
|
|
|
|
92
|
push @glob, grep /^(?:GLOB|FNM|WRDE)_/, keys %$fsys; |
71
|
4
|
|
|
|
|
10
|
my %glob_subset; |
72
|
4
|
|
|
|
|
13
|
@glob_subset{@glob} = @{$fsys}{@glob}; |
|
4
|
|
|
|
|
27
|
|
73
|
4
|
|
|
|
|
13
|
tie %glob, 'POSIX::1003::ReadOnlyTable', \%glob_subset; |
74
|
|
|
|
|
|
|
} |
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
|
3
|
|
|
3
|
0
|
2484
|
{ my ($patterns, %args) = @_; |
87
|
3
|
|
33
|
|
|
21
|
my $flags = $args{flags} |
88
|
|
|
|
|
|
|
// $glob{GLOB_NOSORT}|$glob{GLOB_NOESCAPE}|$glob{GLOB_BRACE}; |
89
|
3
|
|
100
|
0
|
|
16
|
my $errfun = $args{on_error} || sub {0}; |
|
0
|
|
|
|
|
0
|
|
90
|
|
|
|
|
|
|
|
91
|
3
|
|
|
|
|
3
|
my ($err, @fns); |
92
|
3
|
50
|
|
|
|
6
|
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
|
3
|
|
|
|
|
278
|
{ $err = _glob(@fns, $patterns, $flags, $errfun); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
3
|
50
|
33
|
|
|
8
|
if($args{unique} && @fns) |
106
|
0
|
|
|
|
|
0
|
{ my %seen; |
107
|
0
|
|
|
|
|
0
|
@fns = grep !$seen{$_}++, @fns; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
3
|
0
|
33
|
|
|
9
|
$err //= @fns ? $glob{GLOB_NOMATCH} : 0; |
111
|
3
|
|
|
|
|
13
|
($err, \@fns); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
#--------- |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub _create_constant($) |
117
|
58
|
|
|
58
|
|
49
|
{ my ($class, $name) = @_; |
118
|
58
|
|
|
|
|
51
|
my $val = $fsys->{$name}; |
119
|
58
|
|
|
0
|
|
268
|
sub() {$val}; |
|
0
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |