| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CellFunc::File::stat_row; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
440240
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
46
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
81
|
|
|
5
|
1
|
|
|
1
|
|
2349
|
use Log::ger; |
|
|
1
|
|
|
|
|
65
|
|
|
|
1
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
8
|
|
|
|
|
|
|
our $DATE = '2024-12-10'; # DATE |
|
9
|
|
|
|
|
|
|
our $DIST = 'CellFunc-File-stat_row'; # DIST |
|
10
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our %SPEC; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @st_fields = ( |
|
15
|
|
|
|
|
|
|
"dev", # 0 |
|
16
|
|
|
|
|
|
|
"ino", # 1 |
|
17
|
|
|
|
|
|
|
"mode", # 2 |
|
18
|
|
|
|
|
|
|
"nlink", # 3 |
|
19
|
|
|
|
|
|
|
"uid", # 4 |
|
20
|
|
|
|
|
|
|
"gid", # 5 |
|
21
|
|
|
|
|
|
|
"rdev", # 6 |
|
22
|
|
|
|
|
|
|
"size", # 7 |
|
23
|
|
|
|
|
|
|
"atime", # 8 |
|
24
|
|
|
|
|
|
|
"mtime", # 9 |
|
25
|
|
|
|
|
|
|
"ctime", # 10 |
|
26
|
|
|
|
|
|
|
"blksize", # 11 |
|
27
|
|
|
|
|
|
|
"blocks", # 12 |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our @st_field_formats = ( |
|
31
|
|
|
|
|
|
|
"number", # 0 "dev", |
|
32
|
|
|
|
|
|
|
"number", # 1 "ino", |
|
33
|
|
|
|
|
|
|
"", # 2 "mode", |
|
34
|
|
|
|
|
|
|
"number", # 3 "nlink", |
|
35
|
|
|
|
|
|
|
"number", # 4 "uid", |
|
36
|
|
|
|
|
|
|
"number", # 5 "gid", |
|
37
|
|
|
|
|
|
|
"number", # 6 "rdev", |
|
38
|
|
|
|
|
|
|
"filesize", # 7 "size", |
|
39
|
|
|
|
|
|
|
"iso8601_datetime", # 8 "atime", |
|
40
|
|
|
|
|
|
|
"iso8601_datetime", # 9 "mtime", |
|
41
|
|
|
|
|
|
|
"iso8601_datetime", # 10 "ctime", |
|
42
|
|
|
|
|
|
|
"number", # 11 "blksize", |
|
43
|
|
|
|
|
|
|
"number", # 12 "blocks", |
|
44
|
|
|
|
|
|
|
); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our $resmeta = { |
|
47
|
|
|
|
|
|
|
'table.fields' => \@st_fields, |
|
48
|
|
|
|
|
|
|
'table.field_formats' => \@st_field_formats, |
|
49
|
|
|
|
|
|
|
}; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$SPEC{func} = { |
|
52
|
|
|
|
|
|
|
v => 1.1, |
|
53
|
|
|
|
|
|
|
summary => 'Take input value as filename, generate a row from stat()', |
|
54
|
|
|
|
|
|
|
description => <<'MARKDOWN', |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
When file does not exist or cannot be `stat()`'d, will emit a warning and return |
|
57
|
|
|
|
|
|
|
an undefined value instead of a row. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
MARKDOWN |
|
60
|
|
|
|
|
|
|
args => { |
|
61
|
|
|
|
|
|
|
value => { |
|
62
|
|
|
|
|
|
|
schema => 'filename*', |
|
63
|
|
|
|
|
|
|
req => 1, |
|
64
|
|
|
|
|
|
|
pos => 0, |
|
65
|
|
|
|
|
|
|
}, |
|
66
|
|
|
|
|
|
|
follow_symlink => { |
|
67
|
|
|
|
|
|
|
schema => 'bool*', |
|
68
|
|
|
|
|
|
|
default => 1, |
|
69
|
|
|
|
|
|
|
description => <<'MARKDOWN', |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
If set to false, will do an `lstat()` instead of `stat()`. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
MARKDOWN |
|
74
|
|
|
|
|
|
|
}, |
|
75
|
|
|
|
|
|
|
}, |
|
76
|
|
|
|
|
|
|
}; |
|
77
|
|
|
|
|
|
|
sub func { |
|
78
|
0
|
|
|
0
|
1
|
|
my %args = @_; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
0
|
0
|
|
|
|
my @st = ($args{follow_symlink} // 1) ? stat($args{value}) : lstat($args{value}); |
|
81
|
0
|
0
|
|
|
|
|
unless (@st) { |
|
82
|
0
|
|
|
|
|
|
log_warn "Can't stat/lstat(%s): %s", $args{value}, $!; |
|
83
|
0
|
|
|
|
|
|
return [200, "OK"]; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
0
|
|
|
|
|
|
[200, "OK", \@st, $resmeta]; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
|
89
|
|
|
|
|
|
|
# ABSTRACT: Take input value as filename, generate a row from stat() |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |