line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Path; |
2
|
|
|
|
|
|
|
|
3
|
86
|
|
|
86
|
|
2157
|
use 5.018; |
|
86
|
|
|
|
|
293
|
|
4
|
|
|
|
|
|
|
|
5
|
86
|
|
|
86
|
|
450
|
use strict; |
|
86
|
|
|
|
|
158
|
|
|
86
|
|
|
|
|
1686
|
|
6
|
86
|
|
|
86
|
|
378
|
use warnings; |
|
86
|
|
|
|
|
142
|
|
|
86
|
|
|
|
|
2303
|
|
7
|
|
|
|
|
|
|
|
8
|
86
|
|
|
86
|
|
411
|
use Venus::Class 'base', 'with'; |
|
86
|
|
|
|
|
154
|
|
|
86
|
|
|
|
|
465
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
base 'Venus::Kind::Utility'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Venus::Role::Valuable'; |
13
|
|
|
|
|
|
|
with 'Venus::Role::Buildable'; |
14
|
|
|
|
|
|
|
with 'Venus::Role::Accessible'; |
15
|
|
|
|
|
|
|
with 'Venus::Role::Explainable'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use overload ( |
18
|
|
|
|
|
|
|
'""' => 'explain', |
19
|
1
|
|
|
1
|
|
9
|
'eq' => sub{$_[0]->value eq "$_[1]"}, |
20
|
1
|
|
|
1
|
|
11
|
'ne' => sub{$_[0]->value ne "$_[1]"}, |
21
|
1
|
|
|
1
|
|
3
|
'qr' => sub{qr/@{[quotemeta($_[0]->value)]}/}, |
|
1
|
|
|
|
|
4
|
|
22
|
86
|
|
|
|
|
1007
|
'~~' => 'explain', |
23
|
|
|
|
|
|
|
fallback => 1, |
24
|
86
|
|
|
86
|
|
621
|
); |
|
86
|
|
|
|
|
174
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# HOOKS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _exitcode { |
29
|
6
|
|
|
6
|
|
689
|
$? >> 8; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# METHODS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub assertion { |
35
|
4
|
|
|
4
|
1
|
10
|
my ($self) = @_; |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
41
|
my $assert = $self->SUPER::assertion; |
38
|
|
|
|
|
|
|
|
39
|
4
|
|
|
|
|
13
|
$assert->clear->expression('string'); |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
|
|
16
|
return $assert; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub absolute { |
45
|
73
|
|
|
73
|
1
|
160
|
my ($self) = @_; |
46
|
|
|
|
|
|
|
|
47
|
73
|
|
|
|
|
243
|
require File::Spec; |
48
|
|
|
|
|
|
|
|
49
|
73
|
|
|
|
|
299
|
return $self->class->new(File::Spec->rel2abs($self->get)); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub basename { |
53
|
5
|
|
|
5
|
1
|
13
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
|
55
|
5
|
|
|
|
|
24
|
require File::Basename; |
56
|
|
|
|
|
|
|
|
57
|
5
|
|
|
|
|
17
|
return File::Basename::basename($self->get); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub child { |
61
|
51
|
|
|
51
|
1
|
124
|
my ($self, $path) = @_; |
62
|
|
|
|
|
|
|
|
63
|
51
|
|
|
|
|
212
|
require File::Spec; |
64
|
|
|
|
|
|
|
|
65
|
51
|
|
|
|
|
302
|
my @parts = File::Spec->splitdir($path); |
66
|
|
|
|
|
|
|
|
67
|
51
|
|
|
|
|
148
|
return $self->class->new(File::Spec->catfile($self->get, @parts)); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub chmod { |
71
|
1
|
|
|
1
|
1
|
5
|
my ($self, $mode) = @_; |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
5
|
my $path = $self->get; |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
64
|
CORE::chmod($mode, $path); |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
16
|
return $self; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub chown { |
81
|
1
|
|
|
1
|
1
|
4
|
my ($self, @args) = @_; |
82
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
5
|
my $path = $self->get; |
84
|
|
|
|
|
|
|
|
85
|
1
|
|
50
|
|
|
54
|
CORE::chown((map $_||-1, @args[0,1]), $path); |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
16
|
return $self; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub children { |
91
|
28
|
|
|
28
|
1
|
86
|
my ($self) = @_; |
92
|
|
|
|
|
|
|
|
93
|
28
|
|
|
|
|
145
|
require File::Spec; |
94
|
|
|
|
|
|
|
|
95
|
28
|
|
|
|
|
126
|
my @paths = map $self->glob($_), '.??*', '*'; |
96
|
|
|
|
|
|
|
|
97
|
28
|
100
|
|
|
|
185
|
return wantarray ? (@paths) : \@paths; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub copy { |
101
|
1
|
|
|
1
|
1
|
6
|
my ($self, $path) = @_; |
102
|
|
|
|
|
|
|
|
103
|
1
|
|
|
|
|
645
|
require File::Copy; |
104
|
|
|
|
|
|
|
|
105
|
1
|
50
|
|
|
|
2490
|
File::Copy::copy("$self", "$path") |
106
|
|
|
|
|
|
|
or $self->error({throw => 'error_on_copy', error => $!, path => $path}); |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
469
|
return $self; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub default { |
112
|
4
|
|
|
4
|
1
|
28
|
require Cwd; |
113
|
|
|
|
|
|
|
|
114
|
4
|
|
|
|
|
76
|
return Cwd::getcwd(); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub directories { |
118
|
20
|
|
|
20
|
1
|
55
|
my ($self) = @_; |
119
|
|
|
|
|
|
|
|
120
|
20
|
|
|
|
|
52
|
my @paths = grep -d, $self->children; |
121
|
|
|
|
|
|
|
|
122
|
20
|
100
|
|
|
|
87
|
return wantarray ? (@paths) : \@paths; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub exists { |
126
|
28
|
|
|
28
|
1
|
102
|
my ($self) = @_; |
127
|
|
|
|
|
|
|
|
128
|
28
|
|
|
|
|
80
|
return int!!-e $self->get; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub explain { |
132
|
14745
|
|
|
14745
|
1
|
54978
|
my ($self) = @_; |
133
|
|
|
|
|
|
|
|
134
|
14745
|
|
|
|
|
37760
|
return $self->get; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub extension { |
138
|
4
|
|
|
4
|
1
|
11
|
my ($self, $value) = @_; |
139
|
|
|
|
|
|
|
|
140
|
4
|
|
|
|
|
12
|
my $basename = $self->basename; |
141
|
|
|
|
|
|
|
|
142
|
4
|
|
|
|
|
26
|
my ($filename, $suffix) = $basename =~ /^([^\.]+)\.?(.*)$/; |
143
|
|
|
|
|
|
|
|
144
|
4
|
100
|
100
|
|
|
23
|
return $suffix || undef if !$value; |
145
|
|
|
|
|
|
|
|
146
|
2
|
|
|
|
|
26
|
return $self->sibling(join '.', $filename, $value); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub find { |
150
|
3
|
|
|
3
|
1
|
11
|
my ($self, $expr) = @_; |
151
|
|
|
|
|
|
|
|
152
|
3
|
100
|
|
|
|
8
|
$expr = '.*' if !$expr; |
153
|
|
|
|
|
|
|
|
154
|
3
|
50
|
|
|
|
62
|
$expr = qr/$expr/ if ref($expr) ne 'Regexp'; |
155
|
|
|
|
|
|
|
|
156
|
3
|
|
|
|
|
7
|
my @paths; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
push @paths, grep { |
159
|
42
|
|
|
|
|
131
|
$_ =~ $expr |
160
|
|
|
|
|
|
|
} map { |
161
|
3
|
50
|
|
|
|
18
|
$_->is_directory ? $_->find($expr) : $_ |
|
42
|
|
|
|
|
130
|
|
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
$self->children; |
164
|
|
|
|
|
|
|
|
165
|
3
|
50
|
|
|
|
21
|
return wantarray ? (@paths) : \@paths; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub files { |
169
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
170
|
|
|
|
|
|
|
|
171
|
1
|
|
|
|
|
3
|
my @paths = grep -f, $self->children; |
172
|
|
|
|
|
|
|
|
173
|
1
|
50
|
|
|
|
10
|
return wantarray ? (@paths) : \@paths; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub glob { |
177
|
59
|
|
|
59
|
1
|
138
|
my ($self, $expr) = @_; |
178
|
|
|
|
|
|
|
|
179
|
59
|
|
|
|
|
199
|
require File::Spec; |
180
|
|
|
|
|
|
|
|
181
|
59
|
|
100
|
|
|
148
|
$expr ||= '*'; |
182
|
|
|
|
|
|
|
|
183
|
59
|
|
|
|
|
144
|
my @paths = map $self->class->new($_), |
184
|
|
|
|
|
|
|
CORE::glob +File::Spec->catfile($self->absolute, $expr); |
185
|
|
|
|
|
|
|
|
186
|
59
|
100
|
|
|
|
355
|
return wantarray ? (@paths) : \@paths; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub is_absolute { |
190
|
4
|
|
|
4
|
1
|
14
|
my ($self) = @_; |
191
|
|
|
|
|
|
|
|
192
|
4
|
|
|
|
|
20
|
require File::Spec; |
193
|
|
|
|
|
|
|
|
194
|
4
|
|
|
|
|
22
|
return int!!(File::Spec->file_name_is_absolute($self->get)); |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub is_directory { |
198
|
43
|
|
|
43
|
1
|
76
|
my ($self) = @_; |
199
|
|
|
|
|
|
|
|
200
|
43
|
|
|
|
|
146
|
my $path = $self->get; |
201
|
|
|
|
|
|
|
|
202
|
43
|
|
66
|
|
|
1081
|
return int!!(-e $path && -d $path); |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub is_file { |
206
|
11
|
|
|
11
|
1
|
29
|
my ($self) = @_; |
207
|
|
|
|
|
|
|
|
208
|
11
|
|
|
|
|
41
|
my $path = $self->get; |
209
|
|
|
|
|
|
|
|
210
|
11
|
|
100
|
|
|
354
|
return int!!(-e $path && !-d $path); |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub is_relative { |
214
|
3
|
|
|
3
|
1
|
7
|
my ($self) = @_; |
215
|
|
|
|
|
|
|
|
216
|
3
|
|
|
|
|
26
|
return int!$self->is_absolute; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub lines { |
220
|
2
|
|
|
2
|
1
|
8
|
my ($self, $separator, $binmode) = @_; |
221
|
|
|
|
|
|
|
|
222
|
2
|
|
100
|
|
|
9
|
$separator //= "\n"; |
223
|
|
|
|
|
|
|
|
224
|
2
|
50
|
|
|
|
34
|
return [split /$separator/, $binmode ? $self->read($binmode) : $self->read]; |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub lineage { |
228
|
8
|
|
|
8
|
1
|
26
|
my ($self) = @_; |
229
|
|
|
|
|
|
|
|
230
|
8
|
|
|
|
|
35
|
require File::Spec; |
231
|
|
|
|
|
|
|
|
232
|
8
|
|
|
|
|
42
|
my @parts = File::Spec->splitdir($self->get); |
233
|
|
|
|
|
|
|
|
234
|
8
|
|
|
|
|
57
|
my @paths = (( |
235
|
|
|
|
|
|
|
reverse map $self->class->new(File::Spec->catfile(@parts[0..$_])), 1..$#parts |
236
|
|
|
|
|
|
|
), $self->class->new($parts[0])); |
237
|
|
|
|
|
|
|
|
238
|
8
|
100
|
|
|
|
83
|
return wantarray ? (@paths) : \@paths; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub open { |
242
|
12
|
|
|
12
|
1
|
53
|
my ($self, @args) = @_; |
243
|
|
|
|
|
|
|
|
244
|
12
|
|
|
|
|
50
|
my $path = $self->get; |
245
|
|
|
|
|
|
|
|
246
|
12
|
|
|
|
|
75
|
require IO::File; |
247
|
|
|
|
|
|
|
|
248
|
12
|
|
|
|
|
116
|
my $handle = IO::File->new; |
249
|
|
|
|
|
|
|
|
250
|
12
|
100
|
|
|
|
698
|
$handle->open($path, @args) |
251
|
|
|
|
|
|
|
or $self->error({throw => 'error_on_open', path => $path, error => $!}); |
252
|
|
|
|
|
|
|
|
253
|
10
|
|
|
|
|
1225
|
return $handle; |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub mkcall { |
257
|
7
|
|
|
7
|
1
|
30
|
my ($self, @args) = @_; |
258
|
|
|
|
|
|
|
|
259
|
7
|
|
|
|
|
42
|
require File::Spec; |
260
|
|
|
|
|
|
|
|
261
|
7
|
|
|
|
|
34
|
my $path = File::Spec->catfile(File::Spec->splitdir($self->get)); |
262
|
|
|
|
|
|
|
|
263
|
7
|
|
|
|
|
25
|
my $result; |
264
|
|
|
|
|
|
|
|
265
|
7
|
|
|
|
|
27
|
require Venus::Os; |
266
|
|
|
|
|
|
|
|
267
|
7
|
|
|
|
|
50
|
my $args = join ' ', map Venus::Os->quote($_), grep defined, @args; |
268
|
|
|
|
|
|
|
|
269
|
7
|
100
|
|
|
|
67870
|
(defined($result = ($args ? qx($path $args) : qx($path)))) |
|
|
100
|
|
|
|
|
|
270
|
|
|
|
|
|
|
or $self->error({ |
271
|
|
|
|
|
|
|
throw => 'error_on_mkcall', |
272
|
|
|
|
|
|
|
error => $!, |
273
|
|
|
|
|
|
|
exit_code => _exitcode(), |
274
|
|
|
|
|
|
|
path => $path, |
275
|
|
|
|
|
|
|
}); |
276
|
|
|
|
|
|
|
|
277
|
6
|
|
|
|
|
152
|
chomp $result; |
278
|
|
|
|
|
|
|
|
279
|
6
|
100
|
|
|
|
296
|
return wantarray ? ($result, _exitcode()) : $result; |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
sub mkdir { |
283
|
10
|
|
|
10
|
1
|
31
|
my ($self, $mode) = @_; |
284
|
|
|
|
|
|
|
|
285
|
10
|
|
|
|
|
38
|
my $path = $self->get; |
286
|
|
|
|
|
|
|
|
287
|
10
|
50
|
|
|
|
827
|
($mode ? CORE::mkdir($path, $mode) : CORE::mkdir($path)) |
|
|
100
|
|
|
|
|
|
288
|
|
|
|
|
|
|
or $self->error({ |
289
|
|
|
|
|
|
|
throw => 'error_on_mkdir', |
290
|
|
|
|
|
|
|
error => $!, |
291
|
|
|
|
|
|
|
path => $path, |
292
|
|
|
|
|
|
|
}); |
293
|
|
|
|
|
|
|
|
294
|
8
|
|
|
|
|
102
|
return $self; |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
sub mkdirs { |
298
|
4
|
|
|
4
|
1
|
14
|
my ($self, $mode) = @_; |
299
|
|
|
|
|
|
|
|
300
|
4
|
|
|
|
|
9
|
my @paths; |
301
|
|
|
|
|
|
|
|
302
|
4
|
50
|
|
|
|
19
|
for my $path ( |
303
|
|
|
|
|
|
|
grep !!$_, reverse($self->parents), ($self->is_file ? () : $self) |
304
|
|
|
|
|
|
|
) |
305
|
|
|
|
|
|
|
{ |
306
|
12
|
100
|
|
|
|
40
|
if ($path->exists) { |
307
|
7
|
|
|
|
|
27
|
next; |
308
|
|
|
|
|
|
|
} |
309
|
|
|
|
|
|
|
else { |
310
|
5
|
|
|
|
|
35
|
push @paths, $path->mkdir($mode); |
311
|
|
|
|
|
|
|
} |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
|
314
|
4
|
50
|
|
|
|
20
|
return wantarray ? (@paths) : \@paths; |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
sub mktemp_dir { |
318
|
1
|
|
|
1
|
1
|
4
|
my ($self) = @_; |
319
|
|
|
|
|
|
|
|
320
|
1
|
|
|
|
|
1297
|
require File::Temp; |
321
|
|
|
|
|
|
|
|
322
|
1
|
|
|
|
|
11374
|
return $self->class->new(File::Temp::tempdir()); |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
sub mktemp_file { |
326
|
1
|
|
|
1
|
1
|
6
|
my ($self) = @_; |
327
|
|
|
|
|
|
|
|
328
|
1
|
|
|
|
|
4
|
require File::Temp; |
329
|
|
|
|
|
|
|
|
330
|
1
|
|
|
|
|
7
|
return $self->class->new((File::Temp::tempfile())[1]); |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
sub mkfile { |
334
|
9
|
|
|
9
|
1
|
27
|
my ($self) = @_; |
335
|
|
|
|
|
|
|
|
336
|
9
|
|
|
|
|
26
|
my $path = $self->get; |
337
|
|
|
|
|
|
|
|
338
|
9
|
100
|
|
|
|
60
|
return $self if $self->exists; |
339
|
|
|
|
|
|
|
|
340
|
8
|
|
|
|
|
71
|
$self->open('>'); |
341
|
|
|
|
|
|
|
|
342
|
7
|
50
|
|
|
|
197
|
CORE::utime(undef, undef, $path) |
343
|
|
|
|
|
|
|
or $self->error({throw => 'error_on_mkfile', path => $path, error => $!}); |
344
|
|
|
|
|
|
|
|
345
|
7
|
|
|
|
|
191
|
return $self; |
346
|
|
|
|
|
|
|
} |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
sub move { |
349
|
3
|
|
|
3
|
1
|
10
|
my ($self, $path) = @_; |
350
|
|
|
|
|
|
|
|
351
|
3
|
|
|
|
|
14
|
require File::Copy; |
352
|
|
|
|
|
|
|
|
353
|
3
|
50
|
|
|
|
10
|
File::Copy::move("$self", "$path") |
354
|
|
|
|
|
|
|
or $self->error({throw => 'error_on_move', path => $path, error => $!}); |
355
|
|
|
|
|
|
|
|
356
|
3
|
|
|
|
|
400
|
return $self->class->make($path)->absolute; |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
sub name { |
360
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
361
|
|
|
|
|
|
|
|
362
|
1
|
|
|
|
|
5
|
return $self->absolute->get; |
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
sub parent { |
366
|
7
|
|
|
7
|
1
|
25
|
my ($self) = @_; |
367
|
|
|
|
|
|
|
|
368
|
7
|
|
|
|
|
44
|
require File::Spec; |
369
|
|
|
|
|
|
|
|
370
|
7
|
|
|
|
|
45
|
my @parts = File::Spec->splitdir($self->get); |
371
|
|
|
|
|
|
|
|
372
|
7
|
|
|
|
|
118
|
my $path = File::Spec->catfile(@parts[0..$#parts-1]); |
373
|
|
|
|
|
|
|
|
374
|
7
|
50
|
|
|
|
58
|
return defined $path ? $self->class->new($path) : undef; |
375
|
|
|
|
|
|
|
} |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
sub parents { |
378
|
5
|
|
|
5
|
1
|
15
|
my ($self) = @_; |
379
|
|
|
|
|
|
|
|
380
|
5
|
|
|
|
|
27
|
my @paths = $self->lineage; |
381
|
|
|
|
|
|
|
|
382
|
5
|
50
|
|
|
|
43
|
@paths = @paths[1..$#paths] if @paths; |
383
|
|
|
|
|
|
|
|
384
|
5
|
100
|
|
|
|
75
|
return wantarray ? (@paths) : \@paths; |
385
|
|
|
|
|
|
|
} |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
sub parts { |
388
|
1
|
|
|
1
|
1
|
5
|
my ($self) = @_; |
389
|
|
|
|
|
|
|
|
390
|
1
|
|
|
|
|
5
|
require File::Spec; |
391
|
|
|
|
|
|
|
|
392
|
1
|
|
|
|
|
4
|
return [File::Spec->splitdir($self->get)]; |
393
|
|
|
|
|
|
|
} |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
sub read { |
396
|
7208
|
|
|
7208
|
1
|
14689
|
my ($self, $binmode) = @_; |
397
|
|
|
|
|
|
|
|
398
|
7208
|
|
|
|
|
16387
|
my $path = $self->get; |
399
|
|
|
|
|
|
|
|
400
|
7208
|
100
|
|
|
|
344939
|
CORE::open(my $handle, '<', $path) |
401
|
|
|
|
|
|
|
or $self->error({throw => 'error_on_read_open', path => $path, error => $!}); |
402
|
|
|
|
|
|
|
|
403
|
7207
|
50
|
0
|
|
|
31299
|
CORE::binmode($handle, $binmode) or do { |
404
|
0
|
|
|
|
|
0
|
$self->error({ |
405
|
|
|
|
|
|
|
throw => 'error_on_read_binmode', |
406
|
|
|
|
|
|
|
path => $path, |
407
|
|
|
|
|
|
|
error => $!, |
408
|
|
|
|
|
|
|
binmode => $binmode, |
409
|
|
|
|
|
|
|
}); |
410
|
|
|
|
|
|
|
} if defined($binmode); |
411
|
|
|
|
|
|
|
|
412
|
7207
|
|
|
|
|
16286
|
my $result = my $content = ''; |
413
|
|
|
|
|
|
|
|
414
|
7207
|
|
|
|
|
41500
|
while ($result = $handle->sysread(my $buffer, 131072, 0)) { |
415
|
7207
|
|
|
|
|
1529162
|
$content .= $buffer; |
416
|
|
|
|
|
|
|
} |
417
|
|
|
|
|
|
|
|
418
|
7207
|
50
|
|
|
|
130206
|
$self->error({throw => 'error_on_read_error', path => $path, error => $!}) if !defined $result; |
419
|
|
|
|
|
|
|
|
420
|
7207
|
|
|
|
|
95442
|
require Venus::Os; |
421
|
7207
|
100
|
|
|
|
45985
|
$content =~ s/\015\012/\012/g if Venus::Os->is_win; |
422
|
|
|
|
|
|
|
|
423
|
7207
|
|
|
|
|
147145
|
return $content; |
424
|
|
|
|
|
|
|
} |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
sub relative { |
427
|
2
|
|
|
2
|
1
|
6
|
my ($self, $path) = @_; |
428
|
|
|
|
|
|
|
|
429
|
2
|
|
|
|
|
7
|
require File::Spec; |
430
|
|
|
|
|
|
|
|
431
|
2
|
|
33
|
|
|
9
|
$path ||= $self->default; |
432
|
|
|
|
|
|
|
|
433
|
2
|
|
|
|
|
8
|
return $self->class->new(File::Spec->abs2rel($self->get, $path)); |
434
|
|
|
|
|
|
|
} |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
sub rename { |
437
|
2
|
|
|
2
|
1
|
7
|
my ($self, $path) = @_; |
438
|
|
|
|
|
|
|
|
439
|
2
|
|
|
|
|
8
|
$path = $self->class->make($path); |
440
|
|
|
|
|
|
|
|
441
|
2
|
50
|
|
|
|
10
|
$path = $self->sibling("$path") if $path->is_relative; |
442
|
|
|
|
|
|
|
|
443
|
2
|
|
|
|
|
19
|
return $self->move($path); |
444
|
|
|
|
|
|
|
} |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
sub rmdir { |
447
|
4
|
|
|
4
|
1
|
16
|
my ($self) = @_; |
448
|
|
|
|
|
|
|
|
449
|
4
|
|
|
|
|
16
|
my $path = $self->get; |
450
|
|
|
|
|
|
|
|
451
|
4
|
50
|
|
|
|
272
|
CORE::rmdir($path) |
452
|
|
|
|
|
|
|
or $self->error({throw => 'error_on_rmdir', path => $path, error => $!}); |
453
|
|
|
|
|
|
|
|
454
|
4
|
|
|
|
|
34
|
return $self; |
455
|
|
|
|
|
|
|
} |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
sub rmdirs { |
458
|
2
|
|
|
2
|
1
|
7
|
my ($self) = @_; |
459
|
|
|
|
|
|
|
|
460
|
2
|
|
|
|
|
4
|
my @paths; |
461
|
|
|
|
|
|
|
|
462
|
2
|
|
|
|
|
7
|
for my $path ($self->children) { |
463
|
1
|
50
|
|
|
|
15
|
if ($path->is_file) { |
464
|
0
|
|
|
|
|
0
|
push @paths, $path->unlink; |
465
|
|
|
|
|
|
|
} |
466
|
|
|
|
|
|
|
else { |
467
|
1
|
|
|
|
|
8
|
push @paths, $path->rmdirs; |
468
|
|
|
|
|
|
|
} |
469
|
|
|
|
|
|
|
} |
470
|
|
|
|
|
|
|
|
471
|
2
|
|
|
|
|
30
|
push @paths, $self->rmdir; |
472
|
|
|
|
|
|
|
|
473
|
2
|
100
|
|
|
|
23
|
return wantarray ? (@paths) : \@paths; |
474
|
|
|
|
|
|
|
} |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
sub rmfiles { |
477
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
478
|
|
|
|
|
|
|
|
479
|
1
|
|
|
|
|
3
|
my @paths; |
480
|
|
|
|
|
|
|
|
481
|
1
|
|
|
|
|
3
|
for my $path ($self->children) { |
482
|
5
|
50
|
|
|
|
29
|
if ($path->is_file) { |
483
|
5
|
|
|
|
|
22
|
push @paths, $path->unlink; |
484
|
|
|
|
|
|
|
} |
485
|
|
|
|
|
|
|
else { |
486
|
0
|
|
|
|
|
0
|
push @paths, $path->rmfiles; |
487
|
|
|
|
|
|
|
} |
488
|
|
|
|
|
|
|
} |
489
|
|
|
|
|
|
|
|
490
|
1
|
50
|
|
|
|
11
|
return wantarray ? (@paths) : \@paths; |
491
|
|
|
|
|
|
|
} |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
sub root { |
494
|
2
|
|
|
2
|
1
|
10
|
my ($self, $spec, $base) = @_; |
495
|
|
|
|
|
|
|
|
496
|
2
|
|
|
|
|
4
|
my @paths; |
497
|
|
|
|
|
|
|
|
498
|
2
|
|
|
|
|
10
|
for my $path ($self->absolute->lineage) { |
499
|
12
|
100
|
|
|
|
37
|
if ($path->child($base)->test($spec)) { |
500
|
1
|
|
|
|
|
5
|
push @paths, $path; |
501
|
1
|
|
|
|
|
4
|
last; |
502
|
|
|
|
|
|
|
} |
503
|
|
|
|
|
|
|
} |
504
|
|
|
|
|
|
|
|
505
|
2
|
50
|
|
|
|
6
|
return @paths ? (-f $paths[0] ? $paths[0]->parent : $paths[0]) : undef; |
|
|
100
|
|
|
|
|
|
506
|
|
|
|
|
|
|
} |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
sub seek { |
509
|
20
|
|
|
20
|
1
|
52
|
my ($self, $spec, $base) = @_; |
510
|
|
|
|
|
|
|
|
511
|
20
|
100
|
|
|
|
42
|
if ((my $path = $self->child($base))->test($spec)) { |
512
|
1
|
|
|
|
|
6
|
return $path; |
513
|
|
|
|
|
|
|
} |
514
|
|
|
|
|
|
|
else { |
515
|
19
|
|
|
|
|
86
|
for my $path ($self->directories) { |
516
|
18
|
|
|
|
|
71
|
my $sought = $path->seek($spec, $base); |
517
|
18
|
100
|
|
|
|
48
|
return $sought if $sought; |
518
|
|
|
|
|
|
|
} |
519
|
17
|
|
|
|
|
48
|
return undef; |
520
|
|
|
|
|
|
|
} |
521
|
|
|
|
|
|
|
} |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
sub sibling { |
524
|
5
|
|
|
5
|
1
|
24
|
my ($self, $path) = @_; |
525
|
|
|
|
|
|
|
|
526
|
5
|
|
|
|
|
27
|
require File::Basename; |
527
|
5
|
|
|
|
|
27
|
require File::Spec; |
528
|
|
|
|
|
|
|
|
529
|
5
|
|
|
|
|
35
|
return $self->class->new(File::Spec->catfile( |
530
|
|
|
|
|
|
|
File::Basename::dirname($self->get), $path)); |
531
|
|
|
|
|
|
|
} |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
sub siblings { |
534
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
535
|
|
|
|
|
|
|
|
536
|
1
|
|
|
|
|
6
|
my @paths = map $self->parent->glob($_), '.??*', '*'; |
537
|
|
|
|
|
|
|
|
538
|
1
|
|
|
|
|
7
|
my %seen = ($self->absolute, 1); |
539
|
|
|
|
|
|
|
|
540
|
1
|
|
|
|
|
3
|
@paths = grep !$seen{$_}++, @paths; |
541
|
|
|
|
|
|
|
|
542
|
1
|
50
|
|
|
|
19
|
return wantarray ? (@paths) : \@paths; |
543
|
|
|
|
|
|
|
} |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
sub test { |
546
|
37
|
|
|
37
|
1
|
1521
|
my ($self, $spec) = @_; |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
return eval( |
549
|
37
|
|
100
|
|
|
2114
|
join(' ', map("-$_", grep(/^[a-zA-Z]$/, split(//, $spec || 'e'))), '$self') |
550
|
|
|
|
|
|
|
); |
551
|
|
|
|
|
|
|
} |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
sub unlink { |
554
|
11
|
|
|
11
|
1
|
864
|
my ($self) = @_; |
555
|
|
|
|
|
|
|
|
556
|
11
|
|
|
|
|
46
|
my $path = $self->get; |
557
|
|
|
|
|
|
|
|
558
|
11
|
100
|
|
|
|
590
|
CORE::unlink($path) |
559
|
|
|
|
|
|
|
or $self->error({throw => 'error_on_unlink', path => $path, error => $!}); |
560
|
|
|
|
|
|
|
|
561
|
10
|
|
|
|
|
77
|
return $self; |
562
|
|
|
|
|
|
|
} |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
sub write { |
565
|
3
|
|
|
3
|
1
|
11
|
my ($self, $data, $binmode) = @_; |
566
|
|
|
|
|
|
|
|
567
|
3
|
|
|
|
|
13
|
my $path = $self->get; |
568
|
|
|
|
|
|
|
|
569
|
3
|
100
|
|
|
|
251
|
CORE::open(my $handle, '>', $path) |
570
|
|
|
|
|
|
|
or $self->error({throw => 'error_on_write_open', path => $path, error => $!}); |
571
|
|
|
|
|
|
|
|
572
|
2
|
50
|
0
|
|
|
17
|
CORE::binmode($handle, $binmode) or do { |
573
|
0
|
|
|
|
|
0
|
$self->error({ |
574
|
|
|
|
|
|
|
throw => 'error_on_write_binmode', |
575
|
|
|
|
|
|
|
path => $path, |
576
|
|
|
|
|
|
|
error => $!, |
577
|
|
|
|
|
|
|
binmode => $binmode, |
578
|
|
|
|
|
|
|
}); |
579
|
|
|
|
|
|
|
} if defined($binmode); |
580
|
|
|
|
|
|
|
|
581
|
2
|
50
|
50
|
|
|
41
|
(($handle->syswrite($data) // -1) == length($data)) |
582
|
|
|
|
|
|
|
or $self->error({throw => 'error_on_write_error', path => $path, error => $!}); |
583
|
|
|
|
|
|
|
|
584
|
2
|
|
|
|
|
195
|
return $self; |
585
|
|
|
|
|
|
|
} |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
# ERRORS |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
sub error_on_copy { |
590
|
1
|
|
|
1
|
1
|
5
|
my ($self, $data) = @_; |
591
|
|
|
|
|
|
|
|
592
|
1
|
|
|
|
|
11
|
my $message = 'Can\'t copy "{{self}}" to "{{path}}": {{error}}'; |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
my $stash = { |
595
|
|
|
|
|
|
|
error => $data->{error}, |
596
|
|
|
|
|
|
|
path => $data->{path}, |
597
|
1
|
|
|
|
|
8
|
self => $self, |
598
|
|
|
|
|
|
|
}; |
599
|
|
|
|
|
|
|
|
600
|
1
|
|
|
|
|
8
|
my $result = { |
601
|
|
|
|
|
|
|
name => 'on.copy', |
602
|
|
|
|
|
|
|
raise => true, |
603
|
|
|
|
|
|
|
stash => $stash, |
604
|
|
|
|
|
|
|
message => $message, |
605
|
|
|
|
|
|
|
}; |
606
|
|
|
|
|
|
|
|
607
|
1
|
|
|
|
|
6
|
return $result; |
608
|
|
|
|
|
|
|
} |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
sub error_on_mkcall { |
611
|
2
|
|
|
2
|
1
|
28
|
my ($self, $data) = @_; |
612
|
|
|
|
|
|
|
|
613
|
2
|
|
|
|
|
21
|
my $error = $data->{error}; |
614
|
2
|
|
100
|
|
|
76
|
my $exit_code = $data->{exit_code} || 0; |
615
|
|
|
|
|
|
|
|
616
|
2
|
100
|
|
|
|
57
|
my $message = ("Can't make system call to \"{{path}}\": " |
617
|
|
|
|
|
|
|
. ($error ? "$error" : sprintf("exit code (%s)", $exit_code))); |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
my $stash = { |
620
|
|
|
|
|
|
|
error => $error, |
621
|
|
|
|
|
|
|
exit_code => $exit_code, |
622
|
|
|
|
|
|
|
path => $data->{path}, |
623
|
2
|
|
|
|
|
24
|
}; |
624
|
|
|
|
|
|
|
|
625
|
2
|
|
|
|
|
32
|
my $result = { |
626
|
|
|
|
|
|
|
name => 'on.mkcall', |
627
|
|
|
|
|
|
|
raise => true, |
628
|
|
|
|
|
|
|
stash => $stash, |
629
|
|
|
|
|
|
|
message => $message, |
630
|
|
|
|
|
|
|
}; |
631
|
|
|
|
|
|
|
|
632
|
2
|
|
|
|
|
17
|
return $result; |
633
|
|
|
|
|
|
|
} |
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
sub error_on_mkdir { |
636
|
3
|
|
|
3
|
1
|
17
|
my ($self, $data) = @_; |
637
|
|
|
|
|
|
|
|
638
|
3
|
|
|
|
|
16
|
my $message = 'Can\'t make directory "{{path}}": {{error}}'; |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
my $stash = { |
641
|
|
|
|
|
|
|
error => $data->{error}, |
642
|
|
|
|
|
|
|
path => $data->{path}, |
643
|
3
|
|
|
|
|
24
|
}; |
644
|
|
|
|
|
|
|
|
645
|
3
|
|
|
|
|
19
|
my $result = { |
646
|
|
|
|
|
|
|
name => 'on.mkdir', |
647
|
|
|
|
|
|
|
raise => true, |
648
|
|
|
|
|
|
|
stash => $stash, |
649
|
|
|
|
|
|
|
message => $message, |
650
|
|
|
|
|
|
|
}; |
651
|
|
|
|
|
|
|
|
652
|
3
|
|
|
|
|
20
|
return $result; |
653
|
|
|
|
|
|
|
} |
654
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
sub error_on_mkfile { |
656
|
1
|
|
|
1
|
1
|
6
|
my ($self, $data) = @_; |
657
|
|
|
|
|
|
|
|
658
|
1
|
|
|
|
|
13
|
my $message = 'Can\'t make file "{{path}}": {{error}}'; |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
my $stash = { |
661
|
|
|
|
|
|
|
error => $data->{error}, |
662
|
|
|
|
|
|
|
path => $data->{path}, |
663
|
1
|
|
|
|
|
8
|
}; |
664
|
|
|
|
|
|
|
|
665
|
1
|
|
|
|
|
7
|
my $result = { |
666
|
|
|
|
|
|
|
name => 'on.mkfile', |
667
|
|
|
|
|
|
|
raise => true, |
668
|
|
|
|
|
|
|
stash => $stash, |
669
|
|
|
|
|
|
|
message => $message, |
670
|
|
|
|
|
|
|
}; |
671
|
|
|
|
|
|
|
|
672
|
1
|
|
|
|
|
5
|
return $result; |
673
|
|
|
|
|
|
|
} |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
sub error_on_move { |
676
|
1
|
|
|
1
|
1
|
5
|
my ($self, $data) = @_; |
677
|
|
|
|
|
|
|
|
678
|
1
|
|
|
|
|
16
|
my $message = 'Can\'t move "{{self}}" to "{{path}}": {{error}}'; |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
my $stash = { |
681
|
|
|
|
|
|
|
error => $data->{error}, |
682
|
|
|
|
|
|
|
path => $data->{path}, |
683
|
1
|
|
|
|
|
11
|
self => $self, |
684
|
|
|
|
|
|
|
}; |
685
|
|
|
|
|
|
|
|
686
|
1
|
|
|
|
|
6
|
my $result = { |
687
|
|
|
|
|
|
|
name => 'on.move', |
688
|
|
|
|
|
|
|
raise => true, |
689
|
|
|
|
|
|
|
stash => $stash, |
690
|
|
|
|
|
|
|
message => $message, |
691
|
|
|
|
|
|
|
}; |
692
|
|
|
|
|
|
|
|
693
|
1
|
|
|
|
|
5
|
return $result; |
694
|
|
|
|
|
|
|
} |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
sub error_on_open { |
697
|
3
|
|
|
3
|
1
|
10
|
my ($self, $data) = @_; |
698
|
|
|
|
|
|
|
|
699
|
3
|
|
|
|
|
9
|
my $message = 'Can\'t open "{{path}}": {{error}}'; |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
my $stash = { |
702
|
|
|
|
|
|
|
error => $data->{error}, |
703
|
|
|
|
|
|
|
path => $data->{path}, |
704
|
3
|
|
|
|
|
14
|
}; |
705
|
|
|
|
|
|
|
|
706
|
3
|
|
|
|
|
16
|
my $result = { |
707
|
|
|
|
|
|
|
name => 'on.open', |
708
|
|
|
|
|
|
|
raise => true, |
709
|
|
|
|
|
|
|
stash => $stash, |
710
|
|
|
|
|
|
|
message => $message, |
711
|
|
|
|
|
|
|
}; |
712
|
|
|
|
|
|
|
|
713
|
3
|
|
|
|
|
11
|
return $result; |
714
|
|
|
|
|
|
|
} |
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
sub error_on_read_binmode { |
717
|
1
|
|
|
1
|
1
|
6
|
my ($self, $data) = @_; |
718
|
|
|
|
|
|
|
|
719
|
1
|
|
|
|
|
15
|
my $message = 'Can\'t binmode "{{path}}": {{error}}'; |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
my $stash = { |
722
|
|
|
|
|
|
|
binmode => $data->{binmode}, |
723
|
|
|
|
|
|
|
error => $data->{error}, |
724
|
|
|
|
|
|
|
path => $data->{path}, |
725
|
1
|
|
|
|
|
12
|
}; |
726
|
|
|
|
|
|
|
|
727
|
1
|
|
|
|
|
8
|
my $result = { |
728
|
|
|
|
|
|
|
name => 'on.read.binmode', |
729
|
|
|
|
|
|
|
raise => true, |
730
|
|
|
|
|
|
|
stash => $stash, |
731
|
|
|
|
|
|
|
message => $message, |
732
|
|
|
|
|
|
|
}; |
733
|
|
|
|
|
|
|
|
734
|
1
|
|
|
|
|
7
|
return $result; |
735
|
|
|
|
|
|
|
} |
736
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
sub error_on_read_error { |
738
|
1
|
|
|
1
|
1
|
6
|
my ($self, $data) = @_; |
739
|
|
|
|
|
|
|
|
740
|
1
|
|
|
|
|
3
|
my $message = 'Can\'t read from file "{{path}}": {{error}}'; |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
my $stash = { |
743
|
|
|
|
|
|
|
error => $data->{error}, |
744
|
|
|
|
|
|
|
path => $data->{path}, |
745
|
1
|
|
|
|
|
6
|
}; |
746
|
|
|
|
|
|
|
|
747
|
1
|
|
|
|
|
6
|
my $result = { |
748
|
|
|
|
|
|
|
name => 'on.read.error', |
749
|
|
|
|
|
|
|
raise => true, |
750
|
|
|
|
|
|
|
stash => $stash, |
751
|
|
|
|
|
|
|
message => $message, |
752
|
|
|
|
|
|
|
}; |
753
|
|
|
|
|
|
|
|
754
|
1
|
|
|
|
|
6
|
return $result; |
755
|
|
|
|
|
|
|
} |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
sub error_on_read_open { |
758
|
2
|
|
|
2
|
1
|
10
|
my ($self, $data) = @_; |
759
|
|
|
|
|
|
|
|
760
|
2
|
|
|
|
|
12
|
my $message = 'Can\'t read "{{path}}": {{error}}'; |
761
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
my $stash = { |
763
|
|
|
|
|
|
|
error => $data->{error}, |
764
|
|
|
|
|
|
|
path => $data->{path}, |
765
|
2
|
|
|
|
|
15
|
}; |
766
|
|
|
|
|
|
|
|
767
|
2
|
|
|
|
|
13
|
my $result = { |
768
|
|
|
|
|
|
|
name => 'on.read.open', |
769
|
|
|
|
|
|
|
raise => true, |
770
|
|
|
|
|
|
|
stash => $stash, |
771
|
|
|
|
|
|
|
message => $message, |
772
|
|
|
|
|
|
|
}; |
773
|
|
|
|
|
|
|
|
774
|
2
|
|
|
|
|
8
|
return $result; |
775
|
|
|
|
|
|
|
} |
776
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
sub error_on_rmdir { |
778
|
1
|
|
|
1
|
1
|
4
|
my ($self, $data) = @_; |
779
|
|
|
|
|
|
|
|
780
|
1
|
|
|
|
|
14
|
my $message = 'Can\'t rmdir "{{path}}": {{error}}'; |
781
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
my $stash = { |
783
|
|
|
|
|
|
|
error => $data->{error}, |
784
|
|
|
|
|
|
|
path => $data->{path}, |
785
|
1
|
|
|
|
|
9
|
}; |
786
|
|
|
|
|
|
|
|
787
|
1
|
|
|
|
|
10
|
my $result = { |
788
|
|
|
|
|
|
|
name => 'on.rmdir', |
789
|
|
|
|
|
|
|
raise => true, |
790
|
|
|
|
|
|
|
stash => $stash, |
791
|
|
|
|
|
|
|
message => $message, |
792
|
|
|
|
|
|
|
}; |
793
|
|
|
|
|
|
|
|
794
|
1
|
|
|
|
|
4
|
return $result; |
795
|
|
|
|
|
|
|
} |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
sub error_on_write_binmode { |
798
|
1
|
|
|
1
|
1
|
6
|
my ($self, $data) = @_; |
799
|
|
|
|
|
|
|
|
800
|
1
|
|
|
|
|
11
|
my $message = 'Can\'t binmode "{{path}}": {{error}}'; |
801
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
my $stash = { |
803
|
|
|
|
|
|
|
binmode => $data->{binmode}, |
804
|
|
|
|
|
|
|
error => $data->{error}, |
805
|
|
|
|
|
|
|
path => $data->{path}, |
806
|
1
|
|
|
|
|
11
|
}; |
807
|
|
|
|
|
|
|
|
808
|
1
|
|
|
|
|
9
|
my $result = { |
809
|
|
|
|
|
|
|
name => 'on.write.binmode', |
810
|
|
|
|
|
|
|
raise => true, |
811
|
|
|
|
|
|
|
stash => $stash, |
812
|
|
|
|
|
|
|
message => $message, |
813
|
|
|
|
|
|
|
}; |
814
|
|
|
|
|
|
|
|
815
|
1
|
|
|
|
|
5
|
return $result; |
816
|
|
|
|
|
|
|
} |
817
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
sub error_on_write_error { |
819
|
1
|
|
|
1
|
1
|
3
|
my ($self, $data) = @_; |
820
|
|
|
|
|
|
|
|
821
|
1
|
|
|
|
|
40
|
my $message = 'Can\'t write to file "{{path}}": {{error}}'; |
822
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
my $stash = { |
824
|
|
|
|
|
|
|
error => $data->{error}, |
825
|
|
|
|
|
|
|
path => $data->{path}, |
826
|
1
|
|
|
|
|
21
|
}; |
827
|
|
|
|
|
|
|
|
828
|
1
|
|
|
|
|
7
|
my $result = { |
829
|
|
|
|
|
|
|
name => 'on.write.error', |
830
|
|
|
|
|
|
|
raise => true, |
831
|
|
|
|
|
|
|
stash => $stash, |
832
|
|
|
|
|
|
|
message => $message, |
833
|
|
|
|
|
|
|
}; |
834
|
|
|
|
|
|
|
|
835
|
1
|
|
|
|
|
6
|
return $result; |
836
|
|
|
|
|
|
|
} |
837
|
|
|
|
|
|
|
|
838
|
|
|
|
|
|
|
sub error_on_write_open { |
839
|
2
|
|
|
2
|
1
|
9
|
my ($self, $data) = @_; |
840
|
|
|
|
|
|
|
|
841
|
2
|
|
|
|
|
14
|
my $message = 'Can\'t write "{{path}}": {{error}}'; |
842
|
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
my $stash = { |
844
|
|
|
|
|
|
|
error => $data->{error}, |
845
|
|
|
|
|
|
|
path => $data->{path}, |
846
|
2
|
|
|
|
|
14
|
}; |
847
|
|
|
|
|
|
|
|
848
|
2
|
|
|
|
|
12
|
my $result = { |
849
|
|
|
|
|
|
|
name => 'on.write.open', |
850
|
|
|
|
|
|
|
raise => true, |
851
|
|
|
|
|
|
|
stash => $stash, |
852
|
|
|
|
|
|
|
message => $message, |
853
|
|
|
|
|
|
|
}; |
854
|
|
|
|
|
|
|
|
855
|
2
|
|
|
|
|
10
|
return $result; |
856
|
|
|
|
|
|
|
} |
857
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
sub error_on_unlink { |
859
|
2
|
|
|
2
|
1
|
10
|
my ($self, $data) = @_; |
860
|
|
|
|
|
|
|
|
861
|
2
|
|
|
|
|
13
|
my $message = 'Can\'t unlink "{{path}}": {{error}}'; |
862
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
my $stash = { |
864
|
|
|
|
|
|
|
error => $data->{error}, |
865
|
|
|
|
|
|
|
path => $data->{path}, |
866
|
2
|
|
|
|
|
21
|
}; |
867
|
|
|
|
|
|
|
|
868
|
2
|
|
|
|
|
11
|
my $result = { |
869
|
|
|
|
|
|
|
name => 'on.unlink', |
870
|
|
|
|
|
|
|
raise => true, |
871
|
|
|
|
|
|
|
stash => $stash, |
872
|
|
|
|
|
|
|
message => $message, |
873
|
|
|
|
|
|
|
}; |
874
|
|
|
|
|
|
|
|
875
|
2
|
|
|
|
|
8
|
return $result; |
876
|
|
|
|
|
|
|
} |
877
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
1; |
879
|
|
|
|
|
|
|
|
880
|
|
|
|
|
|
|
|
881
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
=head1 NAME |
883
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
Venus::Path - Path Class |
885
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
=cut |
887
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
=head1 ABSTRACT |
889
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
Path Class for Perl 5 |
891
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
=cut |
893
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
=head1 SYNOPSIS |
895
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
package main; |
897
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
use Venus::Path; |
899
|
|
|
|
|
|
|
|
900
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/planets'); |
901
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
# my $planets = $path->files; |
903
|
|
|
|
|
|
|
# my $mercury = $path->child('mercury'); |
904
|
|
|
|
|
|
|
# my $content = $mercury->read; |
905
|
|
|
|
|
|
|
|
906
|
|
|
|
|
|
|
=cut |
907
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
=head1 DESCRIPTION |
909
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
This package provides methods for working with file system paths. |
911
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
=cut |
913
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
=head1 INHERITS |
915
|
|
|
|
|
|
|
|
916
|
|
|
|
|
|
|
This package inherits behaviors from: |
917
|
|
|
|
|
|
|
|
918
|
|
|
|
|
|
|
L |
919
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
=cut |
921
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
=head1 INTEGRATES |
923
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
This package integrates behaviors from: |
925
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
L |
927
|
|
|
|
|
|
|
|
928
|
|
|
|
|
|
|
L |
929
|
|
|
|
|
|
|
|
930
|
|
|
|
|
|
|
L |
931
|
|
|
|
|
|
|
|
932
|
|
|
|
|
|
|
L |
933
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
=cut |
935
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
=head1 METHODS |
937
|
|
|
|
|
|
|
|
938
|
|
|
|
|
|
|
This package provides the following methods: |
939
|
|
|
|
|
|
|
|
940
|
|
|
|
|
|
|
=cut |
941
|
|
|
|
|
|
|
|
942
|
|
|
|
|
|
|
=head2 absolute |
943
|
|
|
|
|
|
|
|
944
|
|
|
|
|
|
|
absolute() (Path) |
945
|
|
|
|
|
|
|
|
946
|
|
|
|
|
|
|
The absolute method returns a path object where the value (path) is absolute. |
947
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
I> |
949
|
|
|
|
|
|
|
|
950
|
|
|
|
|
|
|
=over 4 |
951
|
|
|
|
|
|
|
|
952
|
|
|
|
|
|
|
=item absolute example 1 |
953
|
|
|
|
|
|
|
|
954
|
|
|
|
|
|
|
# given: synopsis; |
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
$path = $path->absolute; |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
# bless({ value => "/path/to/t/data/planets" }, "Venus::Path") |
959
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
=back |
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
=cut |
963
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
=head2 basename |
965
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
basename() (Str) |
967
|
|
|
|
|
|
|
|
968
|
|
|
|
|
|
|
The basename method returns the path base name. |
969
|
|
|
|
|
|
|
|
970
|
|
|
|
|
|
|
I> |
971
|
|
|
|
|
|
|
|
972
|
|
|
|
|
|
|
=over 4 |
973
|
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
=item basename example 1 |
975
|
|
|
|
|
|
|
|
976
|
|
|
|
|
|
|
# given: synopsis; |
977
|
|
|
|
|
|
|
|
978
|
|
|
|
|
|
|
my $basename = $path->basename; |
979
|
|
|
|
|
|
|
|
980
|
|
|
|
|
|
|
# planets |
981
|
|
|
|
|
|
|
|
982
|
|
|
|
|
|
|
=back |
983
|
|
|
|
|
|
|
|
984
|
|
|
|
|
|
|
=cut |
985
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
=head2 child |
987
|
|
|
|
|
|
|
|
988
|
|
|
|
|
|
|
child(Str $path) (Path) |
989
|
|
|
|
|
|
|
|
990
|
|
|
|
|
|
|
The child method returns a path object representing the child path provided. |
991
|
|
|
|
|
|
|
|
992
|
|
|
|
|
|
|
I> |
993
|
|
|
|
|
|
|
|
994
|
|
|
|
|
|
|
=over 4 |
995
|
|
|
|
|
|
|
|
996
|
|
|
|
|
|
|
=item child example 1 |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
# given: synopsis; |
999
|
|
|
|
|
|
|
|
1000
|
|
|
|
|
|
|
$path = $path->child('earth'); |
1001
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/earth" }, "Venus::Path") |
1003
|
|
|
|
|
|
|
|
1004
|
|
|
|
|
|
|
=back |
1005
|
|
|
|
|
|
|
|
1006
|
|
|
|
|
|
|
=cut |
1007
|
|
|
|
|
|
|
|
1008
|
|
|
|
|
|
|
=head2 children |
1009
|
|
|
|
|
|
|
|
1010
|
|
|
|
|
|
|
children() (ArrayRef[Path]) |
1011
|
|
|
|
|
|
|
|
1012
|
|
|
|
|
|
|
The children method returns the files and directories under the path. This |
1013
|
|
|
|
|
|
|
method can return a list of values in list-context. |
1014
|
|
|
|
|
|
|
|
1015
|
|
|
|
|
|
|
I> |
1016
|
|
|
|
|
|
|
|
1017
|
|
|
|
|
|
|
=over 4 |
1018
|
|
|
|
|
|
|
|
1019
|
|
|
|
|
|
|
=item children example 1 |
1020
|
|
|
|
|
|
|
|
1021
|
|
|
|
|
|
|
# given: synopsis; |
1022
|
|
|
|
|
|
|
|
1023
|
|
|
|
|
|
|
my $children = $path->children; |
1024
|
|
|
|
|
|
|
|
1025
|
|
|
|
|
|
|
# [ |
1026
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/ceres" }, "Venus::Path"), |
1027
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/earth" }, "Venus::Path"), |
1028
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/eris" }, "Venus::Path"), |
1029
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/haumea" }, "Venus::Path"), |
1030
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/jupiter" }, "Venus::Path"), |
1031
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/makemake" }, "Venus::Path"), |
1032
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/mars" }, "Venus::Path"), |
1033
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/mercury" }, "Venus::Path"), |
1034
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/neptune" }, "Venus::Path"), |
1035
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/planet9" }, "Venus::Path"), |
1036
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/pluto" }, "Venus::Path"), |
1037
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/saturn" }, "Venus::Path"), |
1038
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/uranus" }, "Venus::Path"), |
1039
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/venus" }, "Venus::Path"), |
1040
|
|
|
|
|
|
|
# ] |
1041
|
|
|
|
|
|
|
|
1042
|
|
|
|
|
|
|
=back |
1043
|
|
|
|
|
|
|
|
1044
|
|
|
|
|
|
|
=cut |
1045
|
|
|
|
|
|
|
|
1046
|
|
|
|
|
|
|
=head2 chmod |
1047
|
|
|
|
|
|
|
|
1048
|
|
|
|
|
|
|
chmod(Str $mode) (Path) |
1049
|
|
|
|
|
|
|
|
1050
|
|
|
|
|
|
|
The chmod method changes the file permissions of the file or directory. |
1051
|
|
|
|
|
|
|
|
1052
|
|
|
|
|
|
|
I> |
1053
|
|
|
|
|
|
|
|
1054
|
|
|
|
|
|
|
=over 4 |
1055
|
|
|
|
|
|
|
|
1056
|
|
|
|
|
|
|
=item chmod example 1 |
1057
|
|
|
|
|
|
|
|
1058
|
|
|
|
|
|
|
# given: synopsis; |
1059
|
|
|
|
|
|
|
|
1060
|
|
|
|
|
|
|
$path = $path->chmod(0755); |
1061
|
|
|
|
|
|
|
|
1062
|
|
|
|
|
|
|
# bless({ value => "t/data/planets" }, "Venus::Path") |
1063
|
|
|
|
|
|
|
|
1064
|
|
|
|
|
|
|
=back |
1065
|
|
|
|
|
|
|
|
1066
|
|
|
|
|
|
|
=cut |
1067
|
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
=head2 chown |
1069
|
|
|
|
|
|
|
|
1070
|
|
|
|
|
|
|
chown(Str @args) (Path) |
1071
|
|
|
|
|
|
|
|
1072
|
|
|
|
|
|
|
The chown method changes the group and/or owner or the file or directory. |
1073
|
|
|
|
|
|
|
|
1074
|
|
|
|
|
|
|
I> |
1075
|
|
|
|
|
|
|
|
1076
|
|
|
|
|
|
|
=over 4 |
1077
|
|
|
|
|
|
|
|
1078
|
|
|
|
|
|
|
=item chown example 1 |
1079
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
# given: synopsis; |
1081
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
$path = $path->chown(-1, -1); |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
# bless({ value => "t/data/planets" }, "Venus::Path") |
1085
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
=back |
1087
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
=cut |
1089
|
|
|
|
|
|
|
|
1090
|
|
|
|
|
|
|
=head2 copy |
1091
|
|
|
|
|
|
|
|
1092
|
|
|
|
|
|
|
copy(Str | Path $path) (Path) |
1093
|
|
|
|
|
|
|
|
1094
|
|
|
|
|
|
|
The copy method uses L to copy the file represented by the |
1095
|
|
|
|
|
|
|
invocant to the path provided and returns the invocant. |
1096
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
I> |
1098
|
|
|
|
|
|
|
|
1099
|
|
|
|
|
|
|
=over 4 |
1100
|
|
|
|
|
|
|
|
1101
|
|
|
|
|
|
|
=item copy example 1 |
1102
|
|
|
|
|
|
|
|
1103
|
|
|
|
|
|
|
# given: synopsis |
1104
|
|
|
|
|
|
|
|
1105
|
|
|
|
|
|
|
package main; |
1106
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
my $copy = $path->child('mercury')->copy($path->child('yrucrem')); |
1108
|
|
|
|
|
|
|
|
1109
|
|
|
|
|
|
|
# bless({...}, 'Venus::Path') |
1110
|
|
|
|
|
|
|
|
1111
|
|
|
|
|
|
|
=back |
1112
|
|
|
|
|
|
|
|
1113
|
|
|
|
|
|
|
=cut |
1114
|
|
|
|
|
|
|
|
1115
|
|
|
|
|
|
|
=head2 default |
1116
|
|
|
|
|
|
|
|
1117
|
|
|
|
|
|
|
default() (Str) |
1118
|
|
|
|
|
|
|
|
1119
|
|
|
|
|
|
|
The default method returns the default value, i.e. C<$ENV{PWD}>. |
1120
|
|
|
|
|
|
|
|
1121
|
|
|
|
|
|
|
I> |
1122
|
|
|
|
|
|
|
|
1123
|
|
|
|
|
|
|
=over 4 |
1124
|
|
|
|
|
|
|
|
1125
|
|
|
|
|
|
|
=item default example 1 |
1126
|
|
|
|
|
|
|
|
1127
|
|
|
|
|
|
|
# given: synopsis; |
1128
|
|
|
|
|
|
|
|
1129
|
|
|
|
|
|
|
my $default = $path->default; |
1130
|
|
|
|
|
|
|
|
1131
|
|
|
|
|
|
|
# $ENV{PWD} |
1132
|
|
|
|
|
|
|
|
1133
|
|
|
|
|
|
|
=back |
1134
|
|
|
|
|
|
|
|
1135
|
|
|
|
|
|
|
=cut |
1136
|
|
|
|
|
|
|
|
1137
|
|
|
|
|
|
|
=head2 directories |
1138
|
|
|
|
|
|
|
|
1139
|
|
|
|
|
|
|
directories() (ArrayRef[Path]) |
1140
|
|
|
|
|
|
|
|
1141
|
|
|
|
|
|
|
The directories method returns a list of children under the path which are |
1142
|
|
|
|
|
|
|
directories. This method can return a list of values in list-context. |
1143
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
I> |
1145
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
=over 4 |
1147
|
|
|
|
|
|
|
|
1148
|
|
|
|
|
|
|
=item directories example 1 |
1149
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
# given: synopsis; |
1151
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
my $directories = $path->directories; |
1153
|
|
|
|
|
|
|
|
1154
|
|
|
|
|
|
|
# [] |
1155
|
|
|
|
|
|
|
|
1156
|
|
|
|
|
|
|
=back |
1157
|
|
|
|
|
|
|
|
1158
|
|
|
|
|
|
|
=cut |
1159
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
=head2 exists |
1161
|
|
|
|
|
|
|
|
1162
|
|
|
|
|
|
|
exists() (Bool) |
1163
|
|
|
|
|
|
|
|
1164
|
|
|
|
|
|
|
The exists method returns truthy or falsy if the path exists. |
1165
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
I> |
1167
|
|
|
|
|
|
|
|
1168
|
|
|
|
|
|
|
=over 4 |
1169
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
=item exists example 1 |
1171
|
|
|
|
|
|
|
|
1172
|
|
|
|
|
|
|
# given: synopsis; |
1173
|
|
|
|
|
|
|
|
1174
|
|
|
|
|
|
|
my $exists = $path->exists; |
1175
|
|
|
|
|
|
|
|
1176
|
|
|
|
|
|
|
# 1 |
1177
|
|
|
|
|
|
|
|
1178
|
|
|
|
|
|
|
=back |
1179
|
|
|
|
|
|
|
|
1180
|
|
|
|
|
|
|
=over 4 |
1181
|
|
|
|
|
|
|
|
1182
|
|
|
|
|
|
|
=item exists example 2 |
1183
|
|
|
|
|
|
|
|
1184
|
|
|
|
|
|
|
# given: synopsis; |
1185
|
|
|
|
|
|
|
|
1186
|
|
|
|
|
|
|
my $exists = $path->child('random')->exists; |
1187
|
|
|
|
|
|
|
|
1188
|
|
|
|
|
|
|
# 0 |
1189
|
|
|
|
|
|
|
|
1190
|
|
|
|
|
|
|
=back |
1191
|
|
|
|
|
|
|
|
1192
|
|
|
|
|
|
|
=cut |
1193
|
|
|
|
|
|
|
|
1194
|
|
|
|
|
|
|
=head2 explain |
1195
|
|
|
|
|
|
|
|
1196
|
|
|
|
|
|
|
explain() (Str) |
1197
|
|
|
|
|
|
|
|
1198
|
|
|
|
|
|
|
The explain method returns the path string and is used in stringification |
1199
|
|
|
|
|
|
|
operations. |
1200
|
|
|
|
|
|
|
|
1201
|
|
|
|
|
|
|
I> |
1202
|
|
|
|
|
|
|
|
1203
|
|
|
|
|
|
|
=over 4 |
1204
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
=item explain example 1 |
1206
|
|
|
|
|
|
|
|
1207
|
|
|
|
|
|
|
# given: synopsis; |
1208
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
my $explain = $path->explain; |
1210
|
|
|
|
|
|
|
|
1211
|
|
|
|
|
|
|
# t/data/planets |
1212
|
|
|
|
|
|
|
|
1213
|
|
|
|
|
|
|
=back |
1214
|
|
|
|
|
|
|
|
1215
|
|
|
|
|
|
|
=cut |
1216
|
|
|
|
|
|
|
|
1217
|
|
|
|
|
|
|
=head2 extension |
1218
|
|
|
|
|
|
|
|
1219
|
|
|
|
|
|
|
extension(Str $name) (Str | Path) |
1220
|
|
|
|
|
|
|
|
1221
|
|
|
|
|
|
|
The extension method returns a new path object using the extension name |
1222
|
|
|
|
|
|
|
provided. If no argument is provided this method returns the extension for the |
1223
|
|
|
|
|
|
|
path represented by the invocant, otherwise returns undefined. |
1224
|
|
|
|
|
|
|
|
1225
|
|
|
|
|
|
|
I> |
1226
|
|
|
|
|
|
|
|
1227
|
|
|
|
|
|
|
=over 4 |
1228
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
=item extension example 1 |
1230
|
|
|
|
|
|
|
|
1231
|
|
|
|
|
|
|
package main; |
1232
|
|
|
|
|
|
|
|
1233
|
|
|
|
|
|
|
use Venus::Path; |
1234
|
|
|
|
|
|
|
|
1235
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/Venus_Path.t'); |
1236
|
|
|
|
|
|
|
|
1237
|
|
|
|
|
|
|
my $extension = $path->extension; |
1238
|
|
|
|
|
|
|
|
1239
|
|
|
|
|
|
|
# "t" |
1240
|
|
|
|
|
|
|
|
1241
|
|
|
|
|
|
|
=back |
1242
|
|
|
|
|
|
|
|
1243
|
|
|
|
|
|
|
=over 4 |
1244
|
|
|
|
|
|
|
|
1245
|
|
|
|
|
|
|
=item extension example 2 |
1246
|
|
|
|
|
|
|
|
1247
|
|
|
|
|
|
|
package main; |
1248
|
|
|
|
|
|
|
|
1249
|
|
|
|
|
|
|
use Venus::Path; |
1250
|
|
|
|
|
|
|
|
1251
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/mercury'); |
1252
|
|
|
|
|
|
|
|
1253
|
|
|
|
|
|
|
my $extension = $path->extension('txt'); |
1254
|
|
|
|
|
|
|
|
1255
|
|
|
|
|
|
|
# bless({ value => "t/data/mercury.txt"}, "Venus::Path") |
1256
|
|
|
|
|
|
|
|
1257
|
|
|
|
|
|
|
=back |
1258
|
|
|
|
|
|
|
|
1259
|
|
|
|
|
|
|
=over 4 |
1260
|
|
|
|
|
|
|
|
1261
|
|
|
|
|
|
|
=item extension example 3 |
1262
|
|
|
|
|
|
|
|
1263
|
|
|
|
|
|
|
package main; |
1264
|
|
|
|
|
|
|
|
1265
|
|
|
|
|
|
|
use Venus::Path; |
1266
|
|
|
|
|
|
|
|
1267
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data'); |
1268
|
|
|
|
|
|
|
|
1269
|
|
|
|
|
|
|
my $extension = $path->extension; |
1270
|
|
|
|
|
|
|
|
1271
|
|
|
|
|
|
|
# undef |
1272
|
|
|
|
|
|
|
|
1273
|
|
|
|
|
|
|
=back |
1274
|
|
|
|
|
|
|
|
1275
|
|
|
|
|
|
|
=over 4 |
1276
|
|
|
|
|
|
|
|
1277
|
|
|
|
|
|
|
=item extension example 4 |
1278
|
|
|
|
|
|
|
|
1279
|
|
|
|
|
|
|
package main; |
1280
|
|
|
|
|
|
|
|
1281
|
|
|
|
|
|
|
use Venus::Path; |
1282
|
|
|
|
|
|
|
|
1283
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data'); |
1284
|
|
|
|
|
|
|
|
1285
|
|
|
|
|
|
|
my $extension = $path->extension('txt'); |
1286
|
|
|
|
|
|
|
|
1287
|
|
|
|
|
|
|
# bless({ value => "t/data.txt"}, "Venus::Path") |
1288
|
|
|
|
|
|
|
|
1289
|
|
|
|
|
|
|
=back |
1290
|
|
|
|
|
|
|
|
1291
|
|
|
|
|
|
|
=cut |
1292
|
|
|
|
|
|
|
|
1293
|
|
|
|
|
|
|
=head2 files |
1294
|
|
|
|
|
|
|
|
1295
|
|
|
|
|
|
|
files() (ArrayRef[Path]) |
1296
|
|
|
|
|
|
|
|
1297
|
|
|
|
|
|
|
The files method returns a list of children under the path which are files. |
1298
|
|
|
|
|
|
|
This method can return a list of values in list-context. |
1299
|
|
|
|
|
|
|
|
1300
|
|
|
|
|
|
|
I> |
1301
|
|
|
|
|
|
|
|
1302
|
|
|
|
|
|
|
=over 4 |
1303
|
|
|
|
|
|
|
|
1304
|
|
|
|
|
|
|
=item files example 1 |
1305
|
|
|
|
|
|
|
|
1306
|
|
|
|
|
|
|
# given: synopsis; |
1307
|
|
|
|
|
|
|
|
1308
|
|
|
|
|
|
|
my $files = $path->files; |
1309
|
|
|
|
|
|
|
|
1310
|
|
|
|
|
|
|
# [ |
1311
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/ceres" }, "Venus::Path"), |
1312
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/earth" }, "Venus::Path"), |
1313
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/eris" }, "Venus::Path"), |
1314
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/haumea" }, "Venus::Path"), |
1315
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/jupiter" }, "Venus::Path"), |
1316
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/makemake" }, "Venus::Path"), |
1317
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/mars" }, "Venus::Path"), |
1318
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/mercury" }, "Venus::Path"), |
1319
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/neptune" }, "Venus::Path"), |
1320
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/planet9" }, "Venus::Path"), |
1321
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/pluto" }, "Venus::Path"), |
1322
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/saturn" }, "Venus::Path"), |
1323
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/uranus" }, "Venus::Path"), |
1324
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/venus" }, "Venus::Path"), |
1325
|
|
|
|
|
|
|
# ] |
1326
|
|
|
|
|
|
|
|
1327
|
|
|
|
|
|
|
=back |
1328
|
|
|
|
|
|
|
|
1329
|
|
|
|
|
|
|
=cut |
1330
|
|
|
|
|
|
|
|
1331
|
|
|
|
|
|
|
=head2 find |
1332
|
|
|
|
|
|
|
|
1333
|
|
|
|
|
|
|
find(Str | Regexp $expr) (ArrayRef[Path]) |
1334
|
|
|
|
|
|
|
|
1335
|
|
|
|
|
|
|
The find method does a recursive depth-first search and returns a list of paths |
1336
|
|
|
|
|
|
|
found, matching the expression provided, which defaults to C<*>. This method |
1337
|
|
|
|
|
|
|
can return a list of values in list-context. |
1338
|
|
|
|
|
|
|
|
1339
|
|
|
|
|
|
|
I> |
1340
|
|
|
|
|
|
|
|
1341
|
|
|
|
|
|
|
=over 4 |
1342
|
|
|
|
|
|
|
|
1343
|
|
|
|
|
|
|
=item find example 1 |
1344
|
|
|
|
|
|
|
|
1345
|
|
|
|
|
|
|
# given: synopsis; |
1346
|
|
|
|
|
|
|
|
1347
|
|
|
|
|
|
|
my $find = $path->find; |
1348
|
|
|
|
|
|
|
|
1349
|
|
|
|
|
|
|
# [ |
1350
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/ceres" }, "Venus::Path"), |
1351
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/earth" }, "Venus::Path"), |
1352
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/eris" }, "Venus::Path"), |
1353
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/haumea" }, "Venus::Path"), |
1354
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/jupiter" }, "Venus::Path"), |
1355
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/makemake" }, "Venus::Path"), |
1356
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/mars" }, "Venus::Path"), |
1357
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/mercury" }, "Venus::Path"), |
1358
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/neptune" }, "Venus::Path"), |
1359
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/planet9" }, "Venus::Path"), |
1360
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/pluto" }, "Venus::Path"), |
1361
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/saturn" }, "Venus::Path"), |
1362
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/uranus" }, "Venus::Path"), |
1363
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/venus" }, "Venus::Path"), |
1364
|
|
|
|
|
|
|
# ] |
1365
|
|
|
|
|
|
|
|
1366
|
|
|
|
|
|
|
=back |
1367
|
|
|
|
|
|
|
|
1368
|
|
|
|
|
|
|
=over 4 |
1369
|
|
|
|
|
|
|
|
1370
|
|
|
|
|
|
|
=item find example 2 |
1371
|
|
|
|
|
|
|
|
1372
|
|
|
|
|
|
|
# given: synopsis; |
1373
|
|
|
|
|
|
|
|
1374
|
|
|
|
|
|
|
my $find = $path->find('[:\/\\\.]+m[^:\/\\\.]*$'); |
1375
|
|
|
|
|
|
|
|
1376
|
|
|
|
|
|
|
# [ |
1377
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/makemake" }, "Venus::Path"), |
1378
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/mars" }, "Venus::Path"), |
1379
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/mercury" }, "Venus::Path"), |
1380
|
|
|
|
|
|
|
# ] |
1381
|
|
|
|
|
|
|
|
1382
|
|
|
|
|
|
|
=back |
1383
|
|
|
|
|
|
|
|
1384
|
|
|
|
|
|
|
=over 4 |
1385
|
|
|
|
|
|
|
|
1386
|
|
|
|
|
|
|
=item find example 3 |
1387
|
|
|
|
|
|
|
|
1388
|
|
|
|
|
|
|
# given: synopsis; |
1389
|
|
|
|
|
|
|
|
1390
|
|
|
|
|
|
|
my $find = $path->find('earth'); |
1391
|
|
|
|
|
|
|
|
1392
|
|
|
|
|
|
|
# [ |
1393
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/earth" }, "Venus::Path"), |
1394
|
|
|
|
|
|
|
# ] |
1395
|
|
|
|
|
|
|
|
1396
|
|
|
|
|
|
|
=back |
1397
|
|
|
|
|
|
|
|
1398
|
|
|
|
|
|
|
=cut |
1399
|
|
|
|
|
|
|
|
1400
|
|
|
|
|
|
|
=head2 glob |
1401
|
|
|
|
|
|
|
|
1402
|
|
|
|
|
|
|
glob(Str | Regexp $expr) (ArrayRef[Path]) |
1403
|
|
|
|
|
|
|
|
1404
|
|
|
|
|
|
|
The glob method returns the files and directories under the path matching the |
1405
|
|
|
|
|
|
|
expression provided, which defaults to C<*>. This method can return a list of |
1406
|
|
|
|
|
|
|
values in list-context. |
1407
|
|
|
|
|
|
|
|
1408
|
|
|
|
|
|
|
I> |
1409
|
|
|
|
|
|
|
|
1410
|
|
|
|
|
|
|
=over 4 |
1411
|
|
|
|
|
|
|
|
1412
|
|
|
|
|
|
|
=item glob example 1 |
1413
|
|
|
|
|
|
|
|
1414
|
|
|
|
|
|
|
# given: synopsis; |
1415
|
|
|
|
|
|
|
|
1416
|
|
|
|
|
|
|
my $glob = $path->glob; |
1417
|
|
|
|
|
|
|
|
1418
|
|
|
|
|
|
|
# [ |
1419
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/ceres" }, "Venus::Path"), |
1420
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/earth" }, "Venus::Path"), |
1421
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/eris" }, "Venus::Path"), |
1422
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/haumea" }, "Venus::Path"), |
1423
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/jupiter" }, "Venus::Path"), |
1424
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/makemake" }, "Venus::Path"), |
1425
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/mars" }, "Venus::Path"), |
1426
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/mercury" }, "Venus::Path"), |
1427
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/neptune" }, "Venus::Path"), |
1428
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/planet9" }, "Venus::Path"), |
1429
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/pluto" }, "Venus::Path"), |
1430
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/saturn" }, "Venus::Path"), |
1431
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/uranus" }, "Venus::Path"), |
1432
|
|
|
|
|
|
|
# bless({ value => "t/data/planets/venus" }, "Venus::Path"), |
1433
|
|
|
|
|
|
|
# ] |
1434
|
|
|
|
|
|
|
|
1435
|
|
|
|
|
|
|
=back |
1436
|
|
|
|
|
|
|
|
1437
|
|
|
|
|
|
|
=cut |
1438
|
|
|
|
|
|
|
|
1439
|
|
|
|
|
|
|
=head2 is_absolute |
1440
|
|
|
|
|
|
|
|
1441
|
|
|
|
|
|
|
is_absolute() (Bool) |
1442
|
|
|
|
|
|
|
|
1443
|
|
|
|
|
|
|
The is_absolute method returns truthy or falsy is the path is absolute. |
1444
|
|
|
|
|
|
|
|
1445
|
|
|
|
|
|
|
I> |
1446
|
|
|
|
|
|
|
|
1447
|
|
|
|
|
|
|
=over 4 |
1448
|
|
|
|
|
|
|
|
1449
|
|
|
|
|
|
|
=item is_absolute example 1 |
1450
|
|
|
|
|
|
|
|
1451
|
|
|
|
|
|
|
# given: synopsis; |
1452
|
|
|
|
|
|
|
|
1453
|
|
|
|
|
|
|
my $is_absolute = $path->is_absolute; |
1454
|
|
|
|
|
|
|
|
1455
|
|
|
|
|
|
|
# 0 |
1456
|
|
|
|
|
|
|
|
1457
|
|
|
|
|
|
|
=back |
1458
|
|
|
|
|
|
|
|
1459
|
|
|
|
|
|
|
=cut |
1460
|
|
|
|
|
|
|
|
1461
|
|
|
|
|
|
|
=head2 is_directory |
1462
|
|
|
|
|
|
|
|
1463
|
|
|
|
|
|
|
is_directory() (Bool) |
1464
|
|
|
|
|
|
|
|
1465
|
|
|
|
|
|
|
The is_directory method returns truthy or falsy is the path is a directory. |
1466
|
|
|
|
|
|
|
|
1467
|
|
|
|
|
|
|
I> |
1468
|
|
|
|
|
|
|
|
1469
|
|
|
|
|
|
|
=over 4 |
1470
|
|
|
|
|
|
|
|
1471
|
|
|
|
|
|
|
=item is_directory example 1 |
1472
|
|
|
|
|
|
|
|
1473
|
|
|
|
|
|
|
# given: synopsis; |
1474
|
|
|
|
|
|
|
|
1475
|
|
|
|
|
|
|
my $is_directory = $path->is_directory; |
1476
|
|
|
|
|
|
|
|
1477
|
|
|
|
|
|
|
# 1 |
1478
|
|
|
|
|
|
|
|
1479
|
|
|
|
|
|
|
=back |
1480
|
|
|
|
|
|
|
|
1481
|
|
|
|
|
|
|
=cut |
1482
|
|
|
|
|
|
|
|
1483
|
|
|
|
|
|
|
=head2 is_file |
1484
|
|
|
|
|
|
|
|
1485
|
|
|
|
|
|
|
is_file() (Bool) |
1486
|
|
|
|
|
|
|
|
1487
|
|
|
|
|
|
|
The is_file method returns truthy or falsy is the path is a file. |
1488
|
|
|
|
|
|
|
|
1489
|
|
|
|
|
|
|
I> |
1490
|
|
|
|
|
|
|
|
1491
|
|
|
|
|
|
|
=over 4 |
1492
|
|
|
|
|
|
|
|
1493
|
|
|
|
|
|
|
=item is_file example 1 |
1494
|
|
|
|
|
|
|
|
1495
|
|
|
|
|
|
|
# given: synopsis; |
1496
|
|
|
|
|
|
|
|
1497
|
|
|
|
|
|
|
my $is_file = $path->is_file; |
1498
|
|
|
|
|
|
|
|
1499
|
|
|
|
|
|
|
# 0 |
1500
|
|
|
|
|
|
|
|
1501
|
|
|
|
|
|
|
=back |
1502
|
|
|
|
|
|
|
|
1503
|
|
|
|
|
|
|
=cut |
1504
|
|
|
|
|
|
|
|
1505
|
|
|
|
|
|
|
=head2 is_relative |
1506
|
|
|
|
|
|
|
|
1507
|
|
|
|
|
|
|
is_relative() (Bool) |
1508
|
|
|
|
|
|
|
|
1509
|
|
|
|
|
|
|
The is_relative method returns truthy or falsy is the path is relative. |
1510
|
|
|
|
|
|
|
|
1511
|
|
|
|
|
|
|
I> |
1512
|
|
|
|
|
|
|
|
1513
|
|
|
|
|
|
|
=over 4 |
1514
|
|
|
|
|
|
|
|
1515
|
|
|
|
|
|
|
=item is_relative example 1 |
1516
|
|
|
|
|
|
|
|
1517
|
|
|
|
|
|
|
# given: synopsis; |
1518
|
|
|
|
|
|
|
|
1519
|
|
|
|
|
|
|
my $is_relative = $path->is_relative; |
1520
|
|
|
|
|
|
|
|
1521
|
|
|
|
|
|
|
# 1 |
1522
|
|
|
|
|
|
|
|
1523
|
|
|
|
|
|
|
=back |
1524
|
|
|
|
|
|
|
|
1525
|
|
|
|
|
|
|
=cut |
1526
|
|
|
|
|
|
|
|
1527
|
|
|
|
|
|
|
=head2 lineage |
1528
|
|
|
|
|
|
|
|
1529
|
|
|
|
|
|
|
lineage() (ArrayRef[Path]) |
1530
|
|
|
|
|
|
|
|
1531
|
|
|
|
|
|
|
The lineage method returns the list of parent paths up to the root path. This |
1532
|
|
|
|
|
|
|
method can return a list of values in list-context. |
1533
|
|
|
|
|
|
|
|
1534
|
|
|
|
|
|
|
I> |
1535
|
|
|
|
|
|
|
|
1536
|
|
|
|
|
|
|
=over 4 |
1537
|
|
|
|
|
|
|
|
1538
|
|
|
|
|
|
|
=item lineage example 1 |
1539
|
|
|
|
|
|
|
|
1540
|
|
|
|
|
|
|
# given: synopsis; |
1541
|
|
|
|
|
|
|
|
1542
|
|
|
|
|
|
|
my $lineage = $path->lineage; |
1543
|
|
|
|
|
|
|
|
1544
|
|
|
|
|
|
|
# [ |
1545
|
|
|
|
|
|
|
# bless({ value => "t/data/planets" }, "Venus::Path"), |
1546
|
|
|
|
|
|
|
# bless({ value => "t/data" }, "Venus::Path"), |
1547
|
|
|
|
|
|
|
# bless({ value => "t" }, "Venus::Path"), |
1548
|
|
|
|
|
|
|
# ] |
1549
|
|
|
|
|
|
|
|
1550
|
|
|
|
|
|
|
=back |
1551
|
|
|
|
|
|
|
|
1552
|
|
|
|
|
|
|
=cut |
1553
|
|
|
|
|
|
|
|
1554
|
|
|
|
|
|
|
=head2 lines |
1555
|
|
|
|
|
|
|
|
1556
|
|
|
|
|
|
|
lines(Str|Regexp $separator, Str $binmode) (ArrayRef[Str]) |
1557
|
|
|
|
|
|
|
|
1558
|
|
|
|
|
|
|
The lines method returns the list of lines from the underlying file. By default |
1559
|
|
|
|
|
|
|
the file contents are separated by newline. |
1560
|
|
|
|
|
|
|
|
1561
|
|
|
|
|
|
|
I> |
1562
|
|
|
|
|
|
|
|
1563
|
|
|
|
|
|
|
=over 4 |
1564
|
|
|
|
|
|
|
|
1565
|
|
|
|
|
|
|
=item lines example 1 |
1566
|
|
|
|
|
|
|
|
1567
|
|
|
|
|
|
|
# given: synopsis; |
1568
|
|
|
|
|
|
|
|
1569
|
|
|
|
|
|
|
my $lines = $path->child('mercury')->lines; |
1570
|
|
|
|
|
|
|
|
1571
|
|
|
|
|
|
|
# ['mercury'] |
1572
|
|
|
|
|
|
|
|
1573
|
|
|
|
|
|
|
=back |
1574
|
|
|
|
|
|
|
|
1575
|
|
|
|
|
|
|
=over 4 |
1576
|
|
|
|
|
|
|
|
1577
|
|
|
|
|
|
|
=item lines example 2 |
1578
|
|
|
|
|
|
|
|
1579
|
|
|
|
|
|
|
# given: synopsis; |
1580
|
|
|
|
|
|
|
|
1581
|
|
|
|
|
|
|
my $lines = $path->child('planet9')->lines($^O =~ /win32/i ? "\n" : "\r\n"); |
1582
|
|
|
|
|
|
|
|
1583
|
|
|
|
|
|
|
# ['planet', 'nine'] |
1584
|
|
|
|
|
|
|
|
1585
|
|
|
|
|
|
|
=back |
1586
|
|
|
|
|
|
|
|
1587
|
|
|
|
|
|
|
=cut |
1588
|
|
|
|
|
|
|
|
1589
|
|
|
|
|
|
|
=head2 mkcall |
1590
|
|
|
|
|
|
|
|
1591
|
|
|
|
|
|
|
mkcall(Any @data) (Any) |
1592
|
|
|
|
|
|
|
|
1593
|
|
|
|
|
|
|
The mkcall method returns the result of executing the path as an executable. In |
1594
|
|
|
|
|
|
|
list context returns the call output and exit code. |
1595
|
|
|
|
|
|
|
|
1596
|
|
|
|
|
|
|
I> |
1597
|
|
|
|
|
|
|
|
1598
|
|
|
|
|
|
|
=over 4 |
1599
|
|
|
|
|
|
|
|
1600
|
|
|
|
|
|
|
=item mkcall example 1 |
1601
|
|
|
|
|
|
|
|
1602
|
|
|
|
|
|
|
package main; |
1603
|
|
|
|
|
|
|
|
1604
|
|
|
|
|
|
|
use Venus::Path; |
1605
|
|
|
|
|
|
|
|
1606
|
|
|
|
|
|
|
my $path = Venus::Path->new($^X); |
1607
|
|
|
|
|
|
|
|
1608
|
|
|
|
|
|
|
my $output = $path->mkcall('--help'); |
1609
|
|
|
|
|
|
|
|
1610
|
|
|
|
|
|
|
# Usage: perl ... |
1611
|
|
|
|
|
|
|
|
1612
|
|
|
|
|
|
|
=back |
1613
|
|
|
|
|
|
|
|
1614
|
|
|
|
|
|
|
=over 4 |
1615
|
|
|
|
|
|
|
|
1616
|
|
|
|
|
|
|
=item mkcall example 2 |
1617
|
|
|
|
|
|
|
|
1618
|
|
|
|
|
|
|
package main; |
1619
|
|
|
|
|
|
|
|
1620
|
|
|
|
|
|
|
use Venus::Path; |
1621
|
|
|
|
|
|
|
|
1622
|
|
|
|
|
|
|
my $path = Venus::Path->new($^X); |
1623
|
|
|
|
|
|
|
|
1624
|
|
|
|
|
|
|
my ($call_output, $exit_code) = $path->mkcall('t/data/sun', '--heat-death'); |
1625
|
|
|
|
|
|
|
|
1626
|
|
|
|
|
|
|
# ("", 1) |
1627
|
|
|
|
|
|
|
|
1628
|
|
|
|
|
|
|
=back |
1629
|
|
|
|
|
|
|
|
1630
|
|
|
|
|
|
|
=over 4 |
1631
|
|
|
|
|
|
|
|
1632
|
|
|
|
|
|
|
=item mkcall example 3 |
1633
|
|
|
|
|
|
|
|
1634
|
|
|
|
|
|
|
package main; |
1635
|
|
|
|
|
|
|
|
1636
|
|
|
|
|
|
|
use Venus::Path; |
1637
|
|
|
|
|
|
|
|
1638
|
|
|
|
|
|
|
my $path = Venus::Path->new('.help'); |
1639
|
|
|
|
|
|
|
|
1640
|
|
|
|
|
|
|
my $output = $path->mkcall; |
1641
|
|
|
|
|
|
|
|
1642
|
|
|
|
|
|
|
# Exception! (isa Venus::Path::Error) (see error_on_mkcall) |
1643
|
|
|
|
|
|
|
|
1644
|
|
|
|
|
|
|
=back |
1645
|
|
|
|
|
|
|
|
1646
|
|
|
|
|
|
|
=cut |
1647
|
|
|
|
|
|
|
|
1648
|
|
|
|
|
|
|
=head2 mkdir |
1649
|
|
|
|
|
|
|
|
1650
|
|
|
|
|
|
|
mkdir(Maybe[Str] $mode) (Path) |
1651
|
|
|
|
|
|
|
|
1652
|
|
|
|
|
|
|
The mkdir method makes the path as a directory. |
1653
|
|
|
|
|
|
|
|
1654
|
|
|
|
|
|
|
I> |
1655
|
|
|
|
|
|
|
|
1656
|
|
|
|
|
|
|
=over 4 |
1657
|
|
|
|
|
|
|
|
1658
|
|
|
|
|
|
|
=item mkdir example 1 |
1659
|
|
|
|
|
|
|
|
1660
|
|
|
|
|
|
|
package main; |
1661
|
|
|
|
|
|
|
|
1662
|
|
|
|
|
|
|
use Venus::Path; |
1663
|
|
|
|
|
|
|
|
1664
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/systems'); |
1665
|
|
|
|
|
|
|
|
1666
|
|
|
|
|
|
|
$path = $path->mkdir; |
1667
|
|
|
|
|
|
|
|
1668
|
|
|
|
|
|
|
# bless({ value => "t/data/systems" }, "Venus::Path") |
1669
|
|
|
|
|
|
|
|
1670
|
|
|
|
|
|
|
=back |
1671
|
|
|
|
|
|
|
|
1672
|
|
|
|
|
|
|
=over 4 |
1673
|
|
|
|
|
|
|
|
1674
|
|
|
|
|
|
|
=item mkdir example 2 |
1675
|
|
|
|
|
|
|
|
1676
|
|
|
|
|
|
|
package main; |
1677
|
|
|
|
|
|
|
|
1678
|
|
|
|
|
|
|
use Venus::Path; |
1679
|
|
|
|
|
|
|
|
1680
|
|
|
|
|
|
|
my $path = Venus::Path->new('/path/to/xyz'); |
1681
|
|
|
|
|
|
|
|
1682
|
|
|
|
|
|
|
$path = $path->mkdir; |
1683
|
|
|
|
|
|
|
|
1684
|
|
|
|
|
|
|
# Exception! (isa Venus::Path::Error) (see error_on_mkdir) |
1685
|
|
|
|
|
|
|
|
1686
|
|
|
|
|
|
|
=back |
1687
|
|
|
|
|
|
|
|
1688
|
|
|
|
|
|
|
=cut |
1689
|
|
|
|
|
|
|
|
1690
|
|
|
|
|
|
|
=head2 mkdirs |
1691
|
|
|
|
|
|
|
|
1692
|
|
|
|
|
|
|
mkdirs(Maybe[Str] $mode) (ArrayRef[Path]) |
1693
|
|
|
|
|
|
|
|
1694
|
|
|
|
|
|
|
The mkdirs method creates parent directories and returns the list of created |
1695
|
|
|
|
|
|
|
directories. This method can return a list of values in list-context. |
1696
|
|
|
|
|
|
|
|
1697
|
|
|
|
|
|
|
I> |
1698
|
|
|
|
|
|
|
|
1699
|
|
|
|
|
|
|
=over 4 |
1700
|
|
|
|
|
|
|
|
1701
|
|
|
|
|
|
|
=item mkdirs example 1 |
1702
|
|
|
|
|
|
|
|
1703
|
|
|
|
|
|
|
package main; |
1704
|
|
|
|
|
|
|
|
1705
|
|
|
|
|
|
|
use Venus::Path; |
1706
|
|
|
|
|
|
|
|
1707
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/systems'); |
1708
|
|
|
|
|
|
|
|
1709
|
|
|
|
|
|
|
my $mkdirs = $path->mkdirs; |
1710
|
|
|
|
|
|
|
|
1711
|
|
|
|
|
|
|
# [ |
1712
|
|
|
|
|
|
|
# bless({ value => "t/data/systems" }, "Venus::Path") |
1713
|
|
|
|
|
|
|
# ] |
1714
|
|
|
|
|
|
|
|
1715
|
|
|
|
|
|
|
=back |
1716
|
|
|
|
|
|
|
|
1717
|
|
|
|
|
|
|
=over 4 |
1718
|
|
|
|
|
|
|
|
1719
|
|
|
|
|
|
|
=item mkdirs example 2 |
1720
|
|
|
|
|
|
|
|
1721
|
|
|
|
|
|
|
package main; |
1722
|
|
|
|
|
|
|
|
1723
|
|
|
|
|
|
|
use Venus::Path; |
1724
|
|
|
|
|
|
|
|
1725
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/systems/solar'); |
1726
|
|
|
|
|
|
|
|
1727
|
|
|
|
|
|
|
my $mkdirs = $path->mkdirs; |
1728
|
|
|
|
|
|
|
|
1729
|
|
|
|
|
|
|
# [ |
1730
|
|
|
|
|
|
|
# bless({ value => "t/data/systems" }, "Venus::Path"), |
1731
|
|
|
|
|
|
|
# bless({ value => "t/data/systems/solar" }, "Venus::Path"), |
1732
|
|
|
|
|
|
|
# ] |
1733
|
|
|
|
|
|
|
|
1734
|
|
|
|
|
|
|
=back |
1735
|
|
|
|
|
|
|
|
1736
|
|
|
|
|
|
|
=cut |
1737
|
|
|
|
|
|
|
|
1738
|
|
|
|
|
|
|
=head2 mkfile |
1739
|
|
|
|
|
|
|
|
1740
|
|
|
|
|
|
|
mkfile() (Path) |
1741
|
|
|
|
|
|
|
|
1742
|
|
|
|
|
|
|
The mkfile method makes the path as an empty file. |
1743
|
|
|
|
|
|
|
|
1744
|
|
|
|
|
|
|
I> |
1745
|
|
|
|
|
|
|
|
1746
|
|
|
|
|
|
|
=over 4 |
1747
|
|
|
|
|
|
|
|
1748
|
|
|
|
|
|
|
=item mkfile example 1 |
1749
|
|
|
|
|
|
|
|
1750
|
|
|
|
|
|
|
package main; |
1751
|
|
|
|
|
|
|
|
1752
|
|
|
|
|
|
|
use Venus::Path; |
1753
|
|
|
|
|
|
|
|
1754
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/moon'); |
1755
|
|
|
|
|
|
|
|
1756
|
|
|
|
|
|
|
$path = $path->mkfile; |
1757
|
|
|
|
|
|
|
|
1758
|
|
|
|
|
|
|
# bless({ value => "t/data/moon" }, "Venus::Path") |
1759
|
|
|
|
|
|
|
|
1760
|
|
|
|
|
|
|
=back |
1761
|
|
|
|
|
|
|
|
1762
|
|
|
|
|
|
|
=over 4 |
1763
|
|
|
|
|
|
|
|
1764
|
|
|
|
|
|
|
=item mkfile example 2 |
1765
|
|
|
|
|
|
|
|
1766
|
|
|
|
|
|
|
package main; |
1767
|
|
|
|
|
|
|
|
1768
|
|
|
|
|
|
|
use Venus::Path; |
1769
|
|
|
|
|
|
|
|
1770
|
|
|
|
|
|
|
my $path = Venus::Path->new('/path/to/xyz'); |
1771
|
|
|
|
|
|
|
|
1772
|
|
|
|
|
|
|
$path = $path->mkfile; |
1773
|
|
|
|
|
|
|
|
1774
|
|
|
|
|
|
|
# Exception! (isa Venus::Path::Error) (see error_on_mkfile) |
1775
|
|
|
|
|
|
|
|
1776
|
|
|
|
|
|
|
=back |
1777
|
|
|
|
|
|
|
|
1778
|
|
|
|
|
|
|
=cut |
1779
|
|
|
|
|
|
|
|
1780
|
|
|
|
|
|
|
=head2 mktemp_dir |
1781
|
|
|
|
|
|
|
|
1782
|
|
|
|
|
|
|
mktemp_dir() (Path) |
1783
|
|
|
|
|
|
|
|
1784
|
|
|
|
|
|
|
The mktemp_dir method uses L to create a temporary |
1785
|
|
|
|
|
|
|
directory which isn't automatically removed and returns a new path object. |
1786
|
|
|
|
|
|
|
|
1787
|
|
|
|
|
|
|
I> |
1788
|
|
|
|
|
|
|
|
1789
|
|
|
|
|
|
|
=over 4 |
1790
|
|
|
|
|
|
|
|
1791
|
|
|
|
|
|
|
=item mktemp_dir example 1 |
1792
|
|
|
|
|
|
|
|
1793
|
|
|
|
|
|
|
# given: synopsis |
1794
|
|
|
|
|
|
|
|
1795
|
|
|
|
|
|
|
package main; |
1796
|
|
|
|
|
|
|
|
1797
|
|
|
|
|
|
|
my $mktemp_dir = $path->mktemp_dir; |
1798
|
|
|
|
|
|
|
|
1799
|
|
|
|
|
|
|
# bless({value => "/tmp/ZnKTxBpuBE"}, "Venus::Path") |
1800
|
|
|
|
|
|
|
|
1801
|
|
|
|
|
|
|
=back |
1802
|
|
|
|
|
|
|
|
1803
|
|
|
|
|
|
|
=cut |
1804
|
|
|
|
|
|
|
|
1805
|
|
|
|
|
|
|
=head2 mktemp_file |
1806
|
|
|
|
|
|
|
|
1807
|
|
|
|
|
|
|
mktemp_file() (Path) |
1808
|
|
|
|
|
|
|
|
1809
|
|
|
|
|
|
|
The mktemp_file method uses L to create a temporary file |
1810
|
|
|
|
|
|
|
which isn't automatically removed and returns a new path object. |
1811
|
|
|
|
|
|
|
|
1812
|
|
|
|
|
|
|
I> |
1813
|
|
|
|
|
|
|
|
1814
|
|
|
|
|
|
|
=over 4 |
1815
|
|
|
|
|
|
|
|
1816
|
|
|
|
|
|
|
=item mktemp_file example 1 |
1817
|
|
|
|
|
|
|
|
1818
|
|
|
|
|
|
|
# given: synopsis |
1819
|
|
|
|
|
|
|
|
1820
|
|
|
|
|
|
|
package main; |
1821
|
|
|
|
|
|
|
|
1822
|
|
|
|
|
|
|
my $mktemp_file = $path->mktemp_file; |
1823
|
|
|
|
|
|
|
|
1824
|
|
|
|
|
|
|
# bless({value => "/tmp/y5MvliBQ2F"}, "Venus::Path") |
1825
|
|
|
|
|
|
|
|
1826
|
|
|
|
|
|
|
=back |
1827
|
|
|
|
|
|
|
|
1828
|
|
|
|
|
|
|
=cut |
1829
|
|
|
|
|
|
|
|
1830
|
|
|
|
|
|
|
=head2 move |
1831
|
|
|
|
|
|
|
|
1832
|
|
|
|
|
|
|
move(Str | Path $path) (Path) |
1833
|
|
|
|
|
|
|
|
1834
|
|
|
|
|
|
|
The move method uses L to move the file represented by the |
1835
|
|
|
|
|
|
|
invocant to the path provided and returns the invocant. |
1836
|
|
|
|
|
|
|
|
1837
|
|
|
|
|
|
|
I> |
1838
|
|
|
|
|
|
|
|
1839
|
|
|
|
|
|
|
=over 4 |
1840
|
|
|
|
|
|
|
|
1841
|
|
|
|
|
|
|
=item move example 1 |
1842
|
|
|
|
|
|
|
|
1843
|
|
|
|
|
|
|
package main; |
1844
|
|
|
|
|
|
|
|
1845
|
|
|
|
|
|
|
use Venus::Path; |
1846
|
|
|
|
|
|
|
|
1847
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data'); |
1848
|
|
|
|
|
|
|
|
1849
|
|
|
|
|
|
|
my $unknown = $path->child('unknown')->mkfile->move($path->child('titan')); |
1850
|
|
|
|
|
|
|
|
1851
|
|
|
|
|
|
|
# bless({value => 't/data/titan'}, 'Venus::Path') |
1852
|
|
|
|
|
|
|
|
1853
|
|
|
|
|
|
|
=back |
1854
|
|
|
|
|
|
|
|
1855
|
|
|
|
|
|
|
=cut |
1856
|
|
|
|
|
|
|
|
1857
|
|
|
|
|
|
|
=head2 name |
1858
|
|
|
|
|
|
|
|
1859
|
|
|
|
|
|
|
name() (Str) |
1860
|
|
|
|
|
|
|
|
1861
|
|
|
|
|
|
|
The name method returns the path as an absolute path. |
1862
|
|
|
|
|
|
|
|
1863
|
|
|
|
|
|
|
I> |
1864
|
|
|
|
|
|
|
|
1865
|
|
|
|
|
|
|
=over 4 |
1866
|
|
|
|
|
|
|
|
1867
|
|
|
|
|
|
|
=item name example 1 |
1868
|
|
|
|
|
|
|
|
1869
|
|
|
|
|
|
|
# given: synopsis; |
1870
|
|
|
|
|
|
|
|
1871
|
|
|
|
|
|
|
my $name = $path->name; |
1872
|
|
|
|
|
|
|
|
1873
|
|
|
|
|
|
|
# /path/to/t/data/planets |
1874
|
|
|
|
|
|
|
|
1875
|
|
|
|
|
|
|
=back |
1876
|
|
|
|
|
|
|
|
1877
|
|
|
|
|
|
|
=cut |
1878
|
|
|
|
|
|
|
|
1879
|
|
|
|
|
|
|
=head2 open |
1880
|
|
|
|
|
|
|
|
1881
|
|
|
|
|
|
|
open(Any @data) (FileHandle) |
1882
|
|
|
|
|
|
|
|
1883
|
|
|
|
|
|
|
The open method creates and returns an open filehandle. |
1884
|
|
|
|
|
|
|
|
1885
|
|
|
|
|
|
|
I> |
1886
|
|
|
|
|
|
|
|
1887
|
|
|
|
|
|
|
=over 4 |
1888
|
|
|
|
|
|
|
|
1889
|
|
|
|
|
|
|
=item open example 1 |
1890
|
|
|
|
|
|
|
|
1891
|
|
|
|
|
|
|
package main; |
1892
|
|
|
|
|
|
|
|
1893
|
|
|
|
|
|
|
use Venus::Path; |
1894
|
|
|
|
|
|
|
|
1895
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/planets/earth'); |
1896
|
|
|
|
|
|
|
|
1897
|
|
|
|
|
|
|
my $fh = $path->open; |
1898
|
|
|
|
|
|
|
|
1899
|
|
|
|
|
|
|
# bless(..., "IO::File"); |
1900
|
|
|
|
|
|
|
|
1901
|
|
|
|
|
|
|
=back |
1902
|
|
|
|
|
|
|
|
1903
|
|
|
|
|
|
|
=over 4 |
1904
|
|
|
|
|
|
|
|
1905
|
|
|
|
|
|
|
=item open example 2 |
1906
|
|
|
|
|
|
|
|
1907
|
|
|
|
|
|
|
package main; |
1908
|
|
|
|
|
|
|
|
1909
|
|
|
|
|
|
|
use Venus::Path; |
1910
|
|
|
|
|
|
|
|
1911
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/planets/earth'); |
1912
|
|
|
|
|
|
|
|
1913
|
|
|
|
|
|
|
my $fh = $path->open('<'); |
1914
|
|
|
|
|
|
|
|
1915
|
|
|
|
|
|
|
# bless(..., "IO::File"); |
1916
|
|
|
|
|
|
|
|
1917
|
|
|
|
|
|
|
=back |
1918
|
|
|
|
|
|
|
|
1919
|
|
|
|
|
|
|
=over 4 |
1920
|
|
|
|
|
|
|
|
1921
|
|
|
|
|
|
|
=item open example 3 |
1922
|
|
|
|
|
|
|
|
1923
|
|
|
|
|
|
|
package main; |
1924
|
|
|
|
|
|
|
|
1925
|
|
|
|
|
|
|
use Venus::Path; |
1926
|
|
|
|
|
|
|
|
1927
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/planets/earth'); |
1928
|
|
|
|
|
|
|
|
1929
|
|
|
|
|
|
|
my $fh = $path->open('>'); |
1930
|
|
|
|
|
|
|
|
1931
|
|
|
|
|
|
|
# bless(..., "IO::File"); |
1932
|
|
|
|
|
|
|
|
1933
|
|
|
|
|
|
|
=back |
1934
|
|
|
|
|
|
|
|
1935
|
|
|
|
|
|
|
=over 4 |
1936
|
|
|
|
|
|
|
|
1937
|
|
|
|
|
|
|
=item open example 4 |
1938
|
|
|
|
|
|
|
|
1939
|
|
|
|
|
|
|
package main; |
1940
|
|
|
|
|
|
|
|
1941
|
|
|
|
|
|
|
use Venus::Path; |
1942
|
|
|
|
|
|
|
|
1943
|
|
|
|
|
|
|
my $path = Venus::Path->new('/path/to/xyz'); |
1944
|
|
|
|
|
|
|
|
1945
|
|
|
|
|
|
|
my $fh = $path->open('>'); |
1946
|
|
|
|
|
|
|
|
1947
|
|
|
|
|
|
|
# Exception! (isa Venus::Path::Error) (see error_on_open) |
1948
|
|
|
|
|
|
|
|
1949
|
|
|
|
|
|
|
=back |
1950
|
|
|
|
|
|
|
|
1951
|
|
|
|
|
|
|
=cut |
1952
|
|
|
|
|
|
|
|
1953
|
|
|
|
|
|
|
=head2 parent |
1954
|
|
|
|
|
|
|
|
1955
|
|
|
|
|
|
|
parent() (Path) |
1956
|
|
|
|
|
|
|
|
1957
|
|
|
|
|
|
|
The parent method returns a path object representing the parent directory. |
1958
|
|
|
|
|
|
|
|
1959
|
|
|
|
|
|
|
I> |
1960
|
|
|
|
|
|
|
|
1961
|
|
|
|
|
|
|
=over 4 |
1962
|
|
|
|
|
|
|
|
1963
|
|
|
|
|
|
|
=item parent example 1 |
1964
|
|
|
|
|
|
|
|
1965
|
|
|
|
|
|
|
# given: synopsis; |
1966
|
|
|
|
|
|
|
|
1967
|
|
|
|
|
|
|
my $parent = $path->parent; |
1968
|
|
|
|
|
|
|
|
1969
|
|
|
|
|
|
|
# bless({ value => "t/data" }, "Venus::Path") |
1970
|
|
|
|
|
|
|
|
1971
|
|
|
|
|
|
|
=back |
1972
|
|
|
|
|
|
|
|
1973
|
|
|
|
|
|
|
=cut |
1974
|
|
|
|
|
|
|
|
1975
|
|
|
|
|
|
|
=head2 parents |
1976
|
|
|
|
|
|
|
|
1977
|
|
|
|
|
|
|
parents() (ArrayRef[Path]) |
1978
|
|
|
|
|
|
|
|
1979
|
|
|
|
|
|
|
The parents method returns is a list of parent directories. This method can |
1980
|
|
|
|
|
|
|
return a list of values in list-context. |
1981
|
|
|
|
|
|
|
|
1982
|
|
|
|
|
|
|
I> |
1983
|
|
|
|
|
|
|
|
1984
|
|
|
|
|
|
|
=over 4 |
1985
|
|
|
|
|
|
|
|
1986
|
|
|
|
|
|
|
=item parents example 1 |
1987
|
|
|
|
|
|
|
|
1988
|
|
|
|
|
|
|
# given: synopsis; |
1989
|
|
|
|
|
|
|
|
1990
|
|
|
|
|
|
|
my $parents = $path->parents; |
1991
|
|
|
|
|
|
|
|
1992
|
|
|
|
|
|
|
# [ |
1993
|
|
|
|
|
|
|
# bless({ value => "t/data" }, "Venus::Path"), |
1994
|
|
|
|
|
|
|
# bless({ value => "t" }, "Venus::Path"), |
1995
|
|
|
|
|
|
|
# ] |
1996
|
|
|
|
|
|
|
|
1997
|
|
|
|
|
|
|
=back |
1998
|
|
|
|
|
|
|
|
1999
|
|
|
|
|
|
|
=cut |
2000
|
|
|
|
|
|
|
|
2001
|
|
|
|
|
|
|
=head2 parts |
2002
|
|
|
|
|
|
|
|
2003
|
|
|
|
|
|
|
parts() (ArrayRef[Str]) |
2004
|
|
|
|
|
|
|
|
2005
|
|
|
|
|
|
|
The parts method returns an arrayref of path parts. |
2006
|
|
|
|
|
|
|
|
2007
|
|
|
|
|
|
|
I> |
2008
|
|
|
|
|
|
|
|
2009
|
|
|
|
|
|
|
=over 4 |
2010
|
|
|
|
|
|
|
|
2011
|
|
|
|
|
|
|
=item parts example 1 |
2012
|
|
|
|
|
|
|
|
2013
|
|
|
|
|
|
|
# given: synopsis; |
2014
|
|
|
|
|
|
|
|
2015
|
|
|
|
|
|
|
my $parts = $path->parts; |
2016
|
|
|
|
|
|
|
|
2017
|
|
|
|
|
|
|
# ["t", "data", "planets"] |
2018
|
|
|
|
|
|
|
|
2019
|
|
|
|
|
|
|
=back |
2020
|
|
|
|
|
|
|
|
2021
|
|
|
|
|
|
|
=cut |
2022
|
|
|
|
|
|
|
|
2023
|
|
|
|
|
|
|
=head2 read |
2024
|
|
|
|
|
|
|
|
2025
|
|
|
|
|
|
|
read(Str $binmode) (Str) |
2026
|
|
|
|
|
|
|
|
2027
|
|
|
|
|
|
|
The read method reads the file and returns its contents. |
2028
|
|
|
|
|
|
|
|
2029
|
|
|
|
|
|
|
I> |
2030
|
|
|
|
|
|
|
|
2031
|
|
|
|
|
|
|
=over 4 |
2032
|
|
|
|
|
|
|
|
2033
|
|
|
|
|
|
|
=item read example 1 |
2034
|
|
|
|
|
|
|
|
2035
|
|
|
|
|
|
|
package main; |
2036
|
|
|
|
|
|
|
|
2037
|
|
|
|
|
|
|
use Venus::Path; |
2038
|
|
|
|
|
|
|
|
2039
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/planets/mars'); |
2040
|
|
|
|
|
|
|
|
2041
|
|
|
|
|
|
|
my $content = $path->read; |
2042
|
|
|
|
|
|
|
|
2043
|
|
|
|
|
|
|
=back |
2044
|
|
|
|
|
|
|
|
2045
|
|
|
|
|
|
|
=over 4 |
2046
|
|
|
|
|
|
|
|
2047
|
|
|
|
|
|
|
=item read example 2 |
2048
|
|
|
|
|
|
|
|
2049
|
|
|
|
|
|
|
package main; |
2050
|
|
|
|
|
|
|
|
2051
|
|
|
|
|
|
|
use Venus::Path; |
2052
|
|
|
|
|
|
|
|
2053
|
|
|
|
|
|
|
my $path = Venus::Path->new('/path/to/xyz'); |
2054
|
|
|
|
|
|
|
|
2055
|
|
|
|
|
|
|
my $content = $path->read; |
2056
|
|
|
|
|
|
|
|
2057
|
|
|
|
|
|
|
# Exception! (isa Venus::Path::Error) (see error_on_read_open) |
2058
|
|
|
|
|
|
|
|
2059
|
|
|
|
|
|
|
=back |
2060
|
|
|
|
|
|
|
|
2061
|
|
|
|
|
|
|
=cut |
2062
|
|
|
|
|
|
|
|
2063
|
|
|
|
|
|
|
=head2 relative |
2064
|
|
|
|
|
|
|
|
2065
|
|
|
|
|
|
|
relative(Str $root) (Path) |
2066
|
|
|
|
|
|
|
|
2067
|
|
|
|
|
|
|
The relative method returns a path object representing a relative path |
2068
|
|
|
|
|
|
|
(relative to the path provided). |
2069
|
|
|
|
|
|
|
|
2070
|
|
|
|
|
|
|
I> |
2071
|
|
|
|
|
|
|
|
2072
|
|
|
|
|
|
|
=over 4 |
2073
|
|
|
|
|
|
|
|
2074
|
|
|
|
|
|
|
=item relative example 1 |
2075
|
|
|
|
|
|
|
|
2076
|
|
|
|
|
|
|
package main; |
2077
|
|
|
|
|
|
|
|
2078
|
|
|
|
|
|
|
use Venus::Path; |
2079
|
|
|
|
|
|
|
|
2080
|
|
|
|
|
|
|
my $path = Venus::Path->new('/path/to/t/data/planets/mars'); |
2081
|
|
|
|
|
|
|
|
2082
|
|
|
|
|
|
|
my $relative = $path->relative('/path'); |
2083
|
|
|
|
|
|
|
|
2084
|
|
|
|
|
|
|
# bless({ value => "to/t/data/planets/mars" }, "Venus::Path") |
2085
|
|
|
|
|
|
|
|
2086
|
|
|
|
|
|
|
=back |
2087
|
|
|
|
|
|
|
|
2088
|
|
|
|
|
|
|
=over 4 |
2089
|
|
|
|
|
|
|
|
2090
|
|
|
|
|
|
|
=item relative example 2 |
2091
|
|
|
|
|
|
|
|
2092
|
|
|
|
|
|
|
package main; |
2093
|
|
|
|
|
|
|
|
2094
|
|
|
|
|
|
|
use Venus::Path; |
2095
|
|
|
|
|
|
|
|
2096
|
|
|
|
|
|
|
my $path = Venus::Path->new('/path/to/t/data/planets/mars'); |
2097
|
|
|
|
|
|
|
|
2098
|
|
|
|
|
|
|
my $relative = $path->relative('/path/to/t'); |
2099
|
|
|
|
|
|
|
|
2100
|
|
|
|
|
|
|
# bless({ value => "data/planets/mars" }, "Venus::Path") |
2101
|
|
|
|
|
|
|
|
2102
|
|
|
|
|
|
|
=back |
2103
|
|
|
|
|
|
|
|
2104
|
|
|
|
|
|
|
=cut |
2105
|
|
|
|
|
|
|
|
2106
|
|
|
|
|
|
|
=head2 rename |
2107
|
|
|
|
|
|
|
|
2108
|
|
|
|
|
|
|
rename(Str | Path $path) (Path) |
2109
|
|
|
|
|
|
|
|
2110
|
|
|
|
|
|
|
The rename method performs a L unless the path provided is only a file |
2111
|
|
|
|
|
|
|
name, in which case it attempts a rename under the directory of the invocant. |
2112
|
|
|
|
|
|
|
|
2113
|
|
|
|
|
|
|
I> |
2114
|
|
|
|
|
|
|
|
2115
|
|
|
|
|
|
|
=over 4 |
2116
|
|
|
|
|
|
|
|
2117
|
|
|
|
|
|
|
=item rename example 1 |
2118
|
|
|
|
|
|
|
|
2119
|
|
|
|
|
|
|
package main; |
2120
|
|
|
|
|
|
|
|
2121
|
|
|
|
|
|
|
use Venus::Path; |
2122
|
|
|
|
|
|
|
|
2123
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/path/001'); |
2124
|
|
|
|
|
|
|
|
2125
|
|
|
|
|
|
|
my $rename = $path->rename('002'); |
2126
|
|
|
|
|
|
|
|
2127
|
|
|
|
|
|
|
# bless({value => 't/path/002'}, 'Venus::Path') |
2128
|
|
|
|
|
|
|
|
2129
|
|
|
|
|
|
|
=back |
2130
|
|
|
|
|
|
|
|
2131
|
|
|
|
|
|
|
=cut |
2132
|
|
|
|
|
|
|
|
2133
|
|
|
|
|
|
|
=head2 rmdir |
2134
|
|
|
|
|
|
|
|
2135
|
|
|
|
|
|
|
rmdir() (Path) |
2136
|
|
|
|
|
|
|
|
2137
|
|
|
|
|
|
|
The rmdir method removes the directory and returns a path object representing |
2138
|
|
|
|
|
|
|
the deleted directory. |
2139
|
|
|
|
|
|
|
|
2140
|
|
|
|
|
|
|
I> |
2141
|
|
|
|
|
|
|
|
2142
|
|
|
|
|
|
|
=over 4 |
2143
|
|
|
|
|
|
|
|
2144
|
|
|
|
|
|
|
=item rmdir example 1 |
2145
|
|
|
|
|
|
|
|
2146
|
|
|
|
|
|
|
package main; |
2147
|
|
|
|
|
|
|
|
2148
|
|
|
|
|
|
|
use Venus::Path; |
2149
|
|
|
|
|
|
|
|
2150
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/stars'); |
2151
|
|
|
|
|
|
|
|
2152
|
|
|
|
|
|
|
my $rmdir = $path->mkdir->rmdir; |
2153
|
|
|
|
|
|
|
|
2154
|
|
|
|
|
|
|
# bless({ value => "t/data/stars" }, "Venus::Path") |
2155
|
|
|
|
|
|
|
|
2156
|
|
|
|
|
|
|
=back |
2157
|
|
|
|
|
|
|
|
2158
|
|
|
|
|
|
|
=over 4 |
2159
|
|
|
|
|
|
|
|
2160
|
|
|
|
|
|
|
=item rmdir example 2 |
2161
|
|
|
|
|
|
|
|
2162
|
|
|
|
|
|
|
package main; |
2163
|
|
|
|
|
|
|
|
2164
|
|
|
|
|
|
|
use Venus::Path; |
2165
|
|
|
|
|
|
|
|
2166
|
|
|
|
|
|
|
my $path = Venus::Path->new('/path/to/xyz'); |
2167
|
|
|
|
|
|
|
|
2168
|
|
|
|
|
|
|
my $rmdir = $path->mkdir->rmdir; |
2169
|
|
|
|
|
|
|
|
2170
|
|
|
|
|
|
|
# Exception! (isa Venus::Path::Error) (see error_on_rmdir) |
2171
|
|
|
|
|
|
|
|
2172
|
|
|
|
|
|
|
=back |
2173
|
|
|
|
|
|
|
|
2174
|
|
|
|
|
|
|
=cut |
2175
|
|
|
|
|
|
|
|
2176
|
|
|
|
|
|
|
=head2 rmdirs |
2177
|
|
|
|
|
|
|
|
2178
|
|
|
|
|
|
|
rmdirs() (ArrayRef[Path]) |
2179
|
|
|
|
|
|
|
|
2180
|
|
|
|
|
|
|
The rmdirs method removes that path and its child files and directories and |
2181
|
|
|
|
|
|
|
returns all paths removed. This method can return a list of values in |
2182
|
|
|
|
|
|
|
list-context. |
2183
|
|
|
|
|
|
|
|
2184
|
|
|
|
|
|
|
I> |
2185
|
|
|
|
|
|
|
|
2186
|
|
|
|
|
|
|
=over 4 |
2187
|
|
|
|
|
|
|
|
2188
|
|
|
|
|
|
|
=item rmdirs example 1 |
2189
|
|
|
|
|
|
|
|
2190
|
|
|
|
|
|
|
package main; |
2191
|
|
|
|
|
|
|
|
2192
|
|
|
|
|
|
|
use Venus::Path; |
2193
|
|
|
|
|
|
|
|
2194
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/stars'); |
2195
|
|
|
|
|
|
|
|
2196
|
|
|
|
|
|
|
$path->child('dwarfs')->mkdirs; |
2197
|
|
|
|
|
|
|
|
2198
|
|
|
|
|
|
|
my $rmdirs = $path->rmdirs; |
2199
|
|
|
|
|
|
|
|
2200
|
|
|
|
|
|
|
# [ |
2201
|
|
|
|
|
|
|
# bless({ value => "t/data/stars/dwarfs" }, "Venus::Path"), |
2202
|
|
|
|
|
|
|
# bless({ value => "t/data/stars" }, "Venus::Path"), |
2203
|
|
|
|
|
|
|
# ] |
2204
|
|
|
|
|
|
|
|
2205
|
|
|
|
|
|
|
=back |
2206
|
|
|
|
|
|
|
|
2207
|
|
|
|
|
|
|
=cut |
2208
|
|
|
|
|
|
|
|
2209
|
|
|
|
|
|
|
=head2 rmfiles |
2210
|
|
|
|
|
|
|
|
2211
|
|
|
|
|
|
|
rmfiles() (ArrayRef[Path]) |
2212
|
|
|
|
|
|
|
|
2213
|
|
|
|
|
|
|
The rmfiles method recursively removes files under the path and returns the |
2214
|
|
|
|
|
|
|
paths removed. This method does not remove the directories found. This method |
2215
|
|
|
|
|
|
|
can return a list of values in list-context. |
2216
|
|
|
|
|
|
|
|
2217
|
|
|
|
|
|
|
I> |
2218
|
|
|
|
|
|
|
|
2219
|
|
|
|
|
|
|
=over 4 |
2220
|
|
|
|
|
|
|
|
2221
|
|
|
|
|
|
|
=item rmfiles example 1 |
2222
|
|
|
|
|
|
|
|
2223
|
|
|
|
|
|
|
package main; |
2224
|
|
|
|
|
|
|
|
2225
|
|
|
|
|
|
|
use Venus::Path; |
2226
|
|
|
|
|
|
|
|
2227
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/stars')->mkdir; |
2228
|
|
|
|
|
|
|
|
2229
|
|
|
|
|
|
|
$path->child('sirius')->mkfile; |
2230
|
|
|
|
|
|
|
$path->child('canopus')->mkfile; |
2231
|
|
|
|
|
|
|
$path->child('arcturus')->mkfile; |
2232
|
|
|
|
|
|
|
$path->child('vega')->mkfile; |
2233
|
|
|
|
|
|
|
$path->child('capella')->mkfile; |
2234
|
|
|
|
|
|
|
|
2235
|
|
|
|
|
|
|
my $rmfiles = $path->rmfiles; |
2236
|
|
|
|
|
|
|
|
2237
|
|
|
|
|
|
|
# [ |
2238
|
|
|
|
|
|
|
# bless({ value => "t/data/stars/arcturus" }, "Venus::Path"), |
2239
|
|
|
|
|
|
|
# bless({ value => "t/data/stars/canopus" }, "Venus::Path"), |
2240
|
|
|
|
|
|
|
# bless({ value => "t/data/stars/capella" }, "Venus::Path"), |
2241
|
|
|
|
|
|
|
# bless({ value => "t/data/stars/sirius" }, "Venus::Path"), |
2242
|
|
|
|
|
|
|
# bless({ value => "t/data/stars/vega" }, "Venus::Path"), |
2243
|
|
|
|
|
|
|
# ] |
2244
|
|
|
|
|
|
|
|
2245
|
|
|
|
|
|
|
=back |
2246
|
|
|
|
|
|
|
|
2247
|
|
|
|
|
|
|
=cut |
2248
|
|
|
|
|
|
|
|
2249
|
|
|
|
|
|
|
=head2 root |
2250
|
|
|
|
|
|
|
|
2251
|
|
|
|
|
|
|
root(Str $spec, Str $base) (Maybe[Path]) |
2252
|
|
|
|
|
|
|
|
2253
|
|
|
|
|
|
|
The root method performs a search up the file system heirarchy returns the |
2254
|
|
|
|
|
|
|
first path (i.e. absolute path) matching the file test specification and base |
2255
|
|
|
|
|
|
|
path expression provided. The file test specification is the same passed to |
2256
|
|
|
|
|
|
|
L. If no path matches are found this method returns underfined. |
2257
|
|
|
|
|
|
|
|
2258
|
|
|
|
|
|
|
I> |
2259
|
|
|
|
|
|
|
|
2260
|
|
|
|
|
|
|
=over 4 |
2261
|
|
|
|
|
|
|
|
2262
|
|
|
|
|
|
|
=item root example 1 |
2263
|
|
|
|
|
|
|
|
2264
|
|
|
|
|
|
|
# given: synopsis; |
2265
|
|
|
|
|
|
|
|
2266
|
|
|
|
|
|
|
my $root = $path->root('d', 't'); |
2267
|
|
|
|
|
|
|
|
2268
|
|
|
|
|
|
|
# bless({ value => "/path/to/t/../" }, "Venus::Path") |
2269
|
|
|
|
|
|
|
|
2270
|
|
|
|
|
|
|
=back |
2271
|
|
|
|
|
|
|
|
2272
|
|
|
|
|
|
|
=over 4 |
2273
|
|
|
|
|
|
|
|
2274
|
|
|
|
|
|
|
=item root example 2 |
2275
|
|
|
|
|
|
|
|
2276
|
|
|
|
|
|
|
# given: synopsis; |
2277
|
|
|
|
|
|
|
|
2278
|
|
|
|
|
|
|
my $root = $path->root('f', 't'); |
2279
|
|
|
|
|
|
|
|
2280
|
|
|
|
|
|
|
# undef |
2281
|
|
|
|
|
|
|
|
2282
|
|
|
|
|
|
|
=back |
2283
|
|
|
|
|
|
|
|
2284
|
|
|
|
|
|
|
=cut |
2285
|
|
|
|
|
|
|
|
2286
|
|
|
|
|
|
|
=head2 seek |
2287
|
|
|
|
|
|
|
|
2288
|
|
|
|
|
|
|
seek(Str $spec, Str $base) (Maybe[Path]) |
2289
|
|
|
|
|
|
|
|
2290
|
|
|
|
|
|
|
The seek method performs a search down the file system heirarchy returns the |
2291
|
|
|
|
|
|
|
first path (i.e. absolute path) matching the file test specification and base |
2292
|
|
|
|
|
|
|
path expression provided. The file test specification is the same passed to |
2293
|
|
|
|
|
|
|
L. If no path matches are found this method returns underfined. |
2294
|
|
|
|
|
|
|
|
2295
|
|
|
|
|
|
|
I> |
2296
|
|
|
|
|
|
|
|
2297
|
|
|
|
|
|
|
=over 4 |
2298
|
|
|
|
|
|
|
|
2299
|
|
|
|
|
|
|
=item seek example 1 |
2300
|
|
|
|
|
|
|
|
2301
|
|
|
|
|
|
|
# given: synopsis; |
2302
|
|
|
|
|
|
|
|
2303
|
|
|
|
|
|
|
$path = Venus::Path->new('t'); |
2304
|
|
|
|
|
|
|
|
2305
|
|
|
|
|
|
|
my $seek = $path->seek('f', 'earth'); |
2306
|
|
|
|
|
|
|
|
2307
|
|
|
|
|
|
|
# bless({ value => "/path/to/t/data/planets/earth" }, "Venus::Path") |
2308
|
|
|
|
|
|
|
|
2309
|
|
|
|
|
|
|
=back |
2310
|
|
|
|
|
|
|
|
2311
|
|
|
|
|
|
|
=over 4 |
2312
|
|
|
|
|
|
|
|
2313
|
|
|
|
|
|
|
=item seek example 2 |
2314
|
|
|
|
|
|
|
|
2315
|
|
|
|
|
|
|
# given: synopsis; |
2316
|
|
|
|
|
|
|
|
2317
|
|
|
|
|
|
|
$path = Venus::Path->new('t'); |
2318
|
|
|
|
|
|
|
|
2319
|
|
|
|
|
|
|
my $seek = $path->seek('f', 'europa'); |
2320
|
|
|
|
|
|
|
|
2321
|
|
|
|
|
|
|
# undef |
2322
|
|
|
|
|
|
|
|
2323
|
|
|
|
|
|
|
=back |
2324
|
|
|
|
|
|
|
|
2325
|
|
|
|
|
|
|
=cut |
2326
|
|
|
|
|
|
|
|
2327
|
|
|
|
|
|
|
=head2 sibling |
2328
|
|
|
|
|
|
|
|
2329
|
|
|
|
|
|
|
sibling(Str $path) (Path) |
2330
|
|
|
|
|
|
|
|
2331
|
|
|
|
|
|
|
The sibling method returns a path object representing the sibling path provided. |
2332
|
|
|
|
|
|
|
|
2333
|
|
|
|
|
|
|
I> |
2334
|
|
|
|
|
|
|
|
2335
|
|
|
|
|
|
|
=over 4 |
2336
|
|
|
|
|
|
|
|
2337
|
|
|
|
|
|
|
=item sibling example 1 |
2338
|
|
|
|
|
|
|
|
2339
|
|
|
|
|
|
|
# given: synopsis; |
2340
|
|
|
|
|
|
|
|
2341
|
|
|
|
|
|
|
my $sibling = $path->sibling('galaxies'); |
2342
|
|
|
|
|
|
|
|
2343
|
|
|
|
|
|
|
# bless({ value => "t/data/galaxies" }, "Venus::Path") |
2344
|
|
|
|
|
|
|
|
2345
|
|
|
|
|
|
|
=back |
2346
|
|
|
|
|
|
|
|
2347
|
|
|
|
|
|
|
=cut |
2348
|
|
|
|
|
|
|
|
2349
|
|
|
|
|
|
|
=head2 siblings |
2350
|
|
|
|
|
|
|
|
2351
|
|
|
|
|
|
|
siblings() (ArrayRef[Path]) |
2352
|
|
|
|
|
|
|
|
2353
|
|
|
|
|
|
|
The siblings method returns all sibling files and directories for the current |
2354
|
|
|
|
|
|
|
path. This method can return a list of values in list-context. |
2355
|
|
|
|
|
|
|
|
2356
|
|
|
|
|
|
|
I> |
2357
|
|
|
|
|
|
|
|
2358
|
|
|
|
|
|
|
=over 4 |
2359
|
|
|
|
|
|
|
|
2360
|
|
|
|
|
|
|
=item siblings example 1 |
2361
|
|
|
|
|
|
|
|
2362
|
|
|
|
|
|
|
# given: synopsis; |
2363
|
|
|
|
|
|
|
|
2364
|
|
|
|
|
|
|
my $siblings = $path->siblings; |
2365
|
|
|
|
|
|
|
|
2366
|
|
|
|
|
|
|
# [ |
2367
|
|
|
|
|
|
|
# bless({ value => "t/data/moon" }, "Venus::Path"), |
2368
|
|
|
|
|
|
|
# bless({ value => "t/data/sun" }, "Venus::Path"), |
2369
|
|
|
|
|
|
|
# ] |
2370
|
|
|
|
|
|
|
|
2371
|
|
|
|
|
|
|
=back |
2372
|
|
|
|
|
|
|
|
2373
|
|
|
|
|
|
|
=cut |
2374
|
|
|
|
|
|
|
|
2375
|
|
|
|
|
|
|
=head2 test |
2376
|
|
|
|
|
|
|
|
2377
|
|
|
|
|
|
|
test(Str $expr) (Bool) |
2378
|
|
|
|
|
|
|
|
2379
|
|
|
|
|
|
|
The test method evaluates the current path against the stackable file test |
2380
|
|
|
|
|
|
|
operators provided. |
2381
|
|
|
|
|
|
|
|
2382
|
|
|
|
|
|
|
I> |
2383
|
|
|
|
|
|
|
|
2384
|
|
|
|
|
|
|
=over 4 |
2385
|
|
|
|
|
|
|
|
2386
|
|
|
|
|
|
|
=item test example 1 |
2387
|
|
|
|
|
|
|
|
2388
|
|
|
|
|
|
|
# given: synopsis; |
2389
|
|
|
|
|
|
|
|
2390
|
|
|
|
|
|
|
my $test = $path->test; |
2391
|
|
|
|
|
|
|
|
2392
|
|
|
|
|
|
|
# -e $path |
2393
|
|
|
|
|
|
|
|
2394
|
|
|
|
|
|
|
# 1 |
2395
|
|
|
|
|
|
|
|
2396
|
|
|
|
|
|
|
=back |
2397
|
|
|
|
|
|
|
|
2398
|
|
|
|
|
|
|
=over 4 |
2399
|
|
|
|
|
|
|
|
2400
|
|
|
|
|
|
|
=item test example 2 |
2401
|
|
|
|
|
|
|
|
2402
|
|
|
|
|
|
|
package main; |
2403
|
|
|
|
|
|
|
|
2404
|
|
|
|
|
|
|
use Venus::Path; |
2405
|
|
|
|
|
|
|
|
2406
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/sun'); |
2407
|
|
|
|
|
|
|
|
2408
|
|
|
|
|
|
|
my $test = $path->test('efs'); |
2409
|
|
|
|
|
|
|
|
2410
|
|
|
|
|
|
|
# -e -f -s $path |
2411
|
|
|
|
|
|
|
|
2412
|
|
|
|
|
|
|
# 1 |
2413
|
|
|
|
|
|
|
|
2414
|
|
|
|
|
|
|
=back |
2415
|
|
|
|
|
|
|
|
2416
|
|
|
|
|
|
|
=cut |
2417
|
|
|
|
|
|
|
|
2418
|
|
|
|
|
|
|
=head2 unlink |
2419
|
|
|
|
|
|
|
|
2420
|
|
|
|
|
|
|
unlink() (Path) |
2421
|
|
|
|
|
|
|
|
2422
|
|
|
|
|
|
|
The unlink method removes the file and returns a path object representing the |
2423
|
|
|
|
|
|
|
removed file. |
2424
|
|
|
|
|
|
|
|
2425
|
|
|
|
|
|
|
I> |
2426
|
|
|
|
|
|
|
|
2427
|
|
|
|
|
|
|
=over 4 |
2428
|
|
|
|
|
|
|
|
2429
|
|
|
|
|
|
|
=item unlink example 1 |
2430
|
|
|
|
|
|
|
|
2431
|
|
|
|
|
|
|
package main; |
2432
|
|
|
|
|
|
|
|
2433
|
|
|
|
|
|
|
use Venus::Path; |
2434
|
|
|
|
|
|
|
|
2435
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/asteroid')->mkfile; |
2436
|
|
|
|
|
|
|
|
2437
|
|
|
|
|
|
|
my $unlink = $path->unlink; |
2438
|
|
|
|
|
|
|
|
2439
|
|
|
|
|
|
|
# bless({ value => "t/data/asteroid" }, "Venus::Path") |
2440
|
|
|
|
|
|
|
|
2441
|
|
|
|
|
|
|
=back |
2442
|
|
|
|
|
|
|
|
2443
|
|
|
|
|
|
|
=over 4 |
2444
|
|
|
|
|
|
|
|
2445
|
|
|
|
|
|
|
=item unlink example 2 |
2446
|
|
|
|
|
|
|
|
2447
|
|
|
|
|
|
|
package main; |
2448
|
|
|
|
|
|
|
|
2449
|
|
|
|
|
|
|
use Venus::Path; |
2450
|
|
|
|
|
|
|
|
2451
|
|
|
|
|
|
|
my $path = Venus::Path->new('/path/to/xyz'); |
2452
|
|
|
|
|
|
|
|
2453
|
|
|
|
|
|
|
my $unlink = $path->unlink; |
2454
|
|
|
|
|
|
|
|
2455
|
|
|
|
|
|
|
# Exception! (isa Venus::Path::Error) (see error_on_unlink) |
2456
|
|
|
|
|
|
|
|
2457
|
|
|
|
|
|
|
=back |
2458
|
|
|
|
|
|
|
|
2459
|
|
|
|
|
|
|
=cut |
2460
|
|
|
|
|
|
|
|
2461
|
|
|
|
|
|
|
=head2 write |
2462
|
|
|
|
|
|
|
|
2463
|
|
|
|
|
|
|
write(Str $data, Str $binmode) (Path) |
2464
|
|
|
|
|
|
|
|
2465
|
|
|
|
|
|
|
The write method write the data provided to the file. |
2466
|
|
|
|
|
|
|
|
2467
|
|
|
|
|
|
|
I> |
2468
|
|
|
|
|
|
|
|
2469
|
|
|
|
|
|
|
=over 4 |
2470
|
|
|
|
|
|
|
|
2471
|
|
|
|
|
|
|
=item write example 1 |
2472
|
|
|
|
|
|
|
|
2473
|
|
|
|
|
|
|
package main; |
2474
|
|
|
|
|
|
|
|
2475
|
|
|
|
|
|
|
use Venus::Path; |
2476
|
|
|
|
|
|
|
|
2477
|
|
|
|
|
|
|
my $path = Venus::Path->new('t/data/asteroid'); |
2478
|
|
|
|
|
|
|
|
2479
|
|
|
|
|
|
|
my $write = $path->write('asteroid'); |
2480
|
|
|
|
|
|
|
|
2481
|
|
|
|
|
|
|
=back |
2482
|
|
|
|
|
|
|
|
2483
|
|
|
|
|
|
|
=over 4 |
2484
|
|
|
|
|
|
|
|
2485
|
|
|
|
|
|
|
=item write example 2 |
2486
|
|
|
|
|
|
|
|
2487
|
|
|
|
|
|
|
package main; |
2488
|
|
|
|
|
|
|
|
2489
|
|
|
|
|
|
|
use Venus::Path; |
2490
|
|
|
|
|
|
|
|
2491
|
|
|
|
|
|
|
my $path = Venus::Path->new('/path/to/xyz'); |
2492
|
|
|
|
|
|
|
|
2493
|
|
|
|
|
|
|
my $write = $path->write('nothing'); |
2494
|
|
|
|
|
|
|
|
2495
|
|
|
|
|
|
|
# Exception! (isa Venus::Path::Error) (see error_on_write_open) |
2496
|
|
|
|
|
|
|
|
2497
|
|
|
|
|
|
|
=back |
2498
|
|
|
|
|
|
|
|
2499
|
|
|
|
|
|
|
=cut |
2500
|
|
|
|
|
|
|
|
2501
|
|
|
|
|
|
|
=head1 ERRORS |
2502
|
|
|
|
|
|
|
|
2503
|
|
|
|
|
|
|
This package may raise the following errors: |
2504
|
|
|
|
|
|
|
|
2505
|
|
|
|
|
|
|
=cut |
2506
|
|
|
|
|
|
|
|
2507
|
|
|
|
|
|
|
=over 4 |
2508
|
|
|
|
|
|
|
|
2509
|
|
|
|
|
|
|
=item error: C |
2510
|
|
|
|
|
|
|
|
2511
|
|
|
|
|
|
|
This package may raise an error_on_copy exception. |
2512
|
|
|
|
|
|
|
|
2513
|
|
|
|
|
|
|
B |
2514
|
|
|
|
|
|
|
|
2515
|
|
|
|
|
|
|
# given: synopsis; |
2516
|
|
|
|
|
|
|
|
2517
|
|
|
|
|
|
|
my $input = { |
2518
|
|
|
|
|
|
|
throw => 'error_on_copy', |
2519
|
|
|
|
|
|
|
error => $!, |
2520
|
|
|
|
|
|
|
path => '/nowhere', |
2521
|
|
|
|
|
|
|
}; |
2522
|
|
|
|
|
|
|
|
2523
|
|
|
|
|
|
|
my $error = $path->catch('error', $input); |
2524
|
|
|
|
|
|
|
|
2525
|
|
|
|
|
|
|
# my $name = $error->name; |
2526
|
|
|
|
|
|
|
|
2527
|
|
|
|
|
|
|
# "on_copy" |
2528
|
|
|
|
|
|
|
|
2529
|
|
|
|
|
|
|
# my $message = $error->render; |
2530
|
|
|
|
|
|
|
|
2531
|
|
|
|
|
|
|
# "Can't copy \"t\/data\/planets\" to \"/nowhere\": $!" |
2532
|
|
|
|
|
|
|
|
2533
|
|
|
|
|
|
|
# my $path = $error->stash('path'); |
2534
|
|
|
|
|
|
|
|
2535
|
|
|
|
|
|
|
# "/nowhere" |
2536
|
|
|
|
|
|
|
|
2537
|
|
|
|
|
|
|
# my $self = $error->stash('self'); |
2538
|
|
|
|
|
|
|
|
2539
|
|
|
|
|
|
|
# bless({...}, 'Venus::Path') |
2540
|
|
|
|
|
|
|
|
2541
|
|
|
|
|
|
|
=back |
2542
|
|
|
|
|
|
|
|
2543
|
|
|
|
|
|
|
=over 4 |
2544
|
|
|
|
|
|
|
|
2545
|
|
|
|
|
|
|
=item error: C |
2546
|
|
|
|
|
|
|
|
2547
|
|
|
|
|
|
|
This package may raise an error_on_mkcall exception. |
2548
|
|
|
|
|
|
|
|
2549
|
|
|
|
|
|
|
B |
2550
|
|
|
|
|
|
|
|
2551
|
|
|
|
|
|
|
# given: synopsis; |
2552
|
|
|
|
|
|
|
|
2553
|
|
|
|
|
|
|
my $input = { |
2554
|
|
|
|
|
|
|
throw => 'error_on_mkcall', |
2555
|
|
|
|
|
|
|
error => $!, |
2556
|
|
|
|
|
|
|
path => '/nowhere', |
2557
|
|
|
|
|
|
|
}; |
2558
|
|
|
|
|
|
|
|
2559
|
|
|
|
|
|
|
my $error = $path->catch('error', $input); |
2560
|
|
|
|
|
|
|
|
2561
|
|
|
|
|
|
|
# my $name = $error->name; |
2562
|
|
|
|
|
|
|
|
2563
|
|
|
|
|
|
|
# "on_mkcall" |
2564
|
|
|
|
|
|
|
|
2565
|
|
|
|
|
|
|
# my $message = $error->render; |
2566
|
|
|
|
|
|
|
|
2567
|
|
|
|
|
|
|
# "Can't make system call to \"/nowhere\": $!" |
2568
|
|
|
|
|
|
|
|
2569
|
|
|
|
|
|
|
# my $path = $error->stash('path'); |
2570
|
|
|
|
|
|
|
|
2571
|
|
|
|
|
|
|
# "/nowhere" |
2572
|
|
|
|
|
|
|
|
2573
|
|
|
|
|
|
|
=back |
2574
|
|
|
|
|
|
|
|
2575
|
|
|
|
|
|
|
=over 4 |
2576
|
|
|
|
|
|
|
|
2577
|
|
|
|
|
|
|
=item error: C |
2578
|
|
|
|
|
|
|
|
2579
|
|
|
|
|
|
|
This package may raise an error_on_mkdir exception. |
2580
|
|
|
|
|
|
|
|
2581
|
|
|
|
|
|
|
B |
2582
|
|
|
|
|
|
|
|
2583
|
|
|
|
|
|
|
# given: synopsis; |
2584
|
|
|
|
|
|
|
|
2585
|
|
|
|
|
|
|
my $input = { |
2586
|
|
|
|
|
|
|
throw => 'error_on_mkdir', |
2587
|
|
|
|
|
|
|
error => $!, |
2588
|
|
|
|
|
|
|
path => '/nowhere', |
2589
|
|
|
|
|
|
|
}; |
2590
|
|
|
|
|
|
|
|
2591
|
|
|
|
|
|
|
my $error = $path->catch('error', $input); |
2592
|
|
|
|
|
|
|
|
2593
|
|
|
|
|
|
|
# my $name = $error->name; |
2594
|
|
|
|
|
|
|
|
2595
|
|
|
|
|
|
|
# "on_mkdir" |
2596
|
|
|
|
|
|
|
|
2597
|
|
|
|
|
|
|
# my $message = $error->render; |
2598
|
|
|
|
|
|
|
|
2599
|
|
|
|
|
|
|
# "Can't make directory \"/nowhere\": $!" |
2600
|
|
|
|
|
|
|
|
2601
|
|
|
|
|
|
|
# my $path = $error->stash('path'); |
2602
|
|
|
|
|
|
|
|
2603
|
|
|
|
|
|
|
# "/nowhere" |
2604
|
|
|
|
|
|
|
|
2605
|
|
|
|
|
|
|
=back |
2606
|
|
|
|
|
|
|
|
2607
|
|
|
|
|
|
|
=over 4 |
2608
|
|
|
|
|
|
|
|
2609
|
|
|
|
|
|
|
=item error: C |
2610
|
|
|
|
|
|
|
|
2611
|
|
|
|
|
|
|
This package may raise an error_on_mkfile exception. |
2612
|
|
|
|
|
|
|
|
2613
|
|
|
|
|
|
|
B |
2614
|
|
|
|
|
|
|
|
2615
|
|
|
|
|
|
|
# given: synopsis; |
2616
|
|
|
|
|
|
|
|
2617
|
|
|
|
|
|
|
my $input = { |
2618
|
|
|
|
|
|
|
throw => 'error_on_mkfile', |
2619
|
|
|
|
|
|
|
error => $!, |
2620
|
|
|
|
|
|
|
path => '/nowhere', |
2621
|
|
|
|
|
|
|
}; |
2622
|
|
|
|
|
|
|
|
2623
|
|
|
|
|
|
|
my $error = $path->catch('error', $input); |
2624
|
|
|
|
|
|
|
|
2625
|
|
|
|
|
|
|
# my $name = $error->name; |
2626
|
|
|
|
|
|
|
|
2627
|
|
|
|
|
|
|
# "on_mkfile" |
2628
|
|
|
|
|
|
|
|
2629
|
|
|
|
|
|
|
# my $message = $error->render; |
2630
|
|
|
|
|
|
|
|
2631
|
|
|
|
|
|
|
# "Can't make file \"/nowhere\": $!" |
2632
|
|
|
|
|
|
|
|
2633
|
|
|
|
|
|
|
# my $path = $error->stash('path'); |
2634
|
|
|
|
|
|
|
|
2635
|
|
|
|
|
|
|
# "/nowhere" |
2636
|
|
|
|
|
|
|
|
2637
|
|
|
|
|
|
|
=back |
2638
|
|
|
|
|
|
|
|
2639
|
|
|
|
|
|
|
=over 4 |
2640
|
|
|
|
|
|
|
|
2641
|
|
|
|
|
|
|
=item error: C |
2642
|
|
|
|
|
|
|
|
2643
|
|
|
|
|
|
|
This package may raise an error_on_move exception. |
2644
|
|
|
|
|
|
|
|
2645
|
|
|
|
|
|
|
B |
2646
|
|
|
|
|
|
|
|
2647
|
|
|
|
|
|
|
# given: synopsis; |
2648
|
|
|
|
|
|
|
|
2649
|
|
|
|
|
|
|
my $input = { |
2650
|
|
|
|
|
|
|
throw => 'error_on_move', |
2651
|
|
|
|
|
|
|
error => $!, |
2652
|
|
|
|
|
|
|
path => '/nowhere', |
2653
|
|
|
|
|
|
|
}; |
2654
|
|
|
|
|
|
|
|
2655
|
|
|
|
|
|
|
my $error = $path->catch('error', $input); |
2656
|
|
|
|
|
|
|
|
2657
|
|
|
|
|
|
|
# my $name = $error->name; |
2658
|
|
|
|
|
|
|
|
2659
|
|
|
|
|
|
|
# "on_move" |
2660
|
|
|
|
|
|
|
|
2661
|
|
|
|
|
|
|
# my $message = $error->render; |
2662
|
|
|
|
|
|
|
|
2663
|
|
|
|
|
|
|
# "Can't copy \"t\/data\/planets\" to \"/nowhere\": $!" |
2664
|
|
|
|
|
|
|
|
2665
|
|
|
|
|
|
|
# my $path = $error->stash('path'); |
2666
|
|
|
|
|
|
|
|
2667
|
|
|
|
|
|
|
# "/nowhere" |
2668
|
|
|
|
|
|
|
|
2669
|
|
|
|
|
|
|
# my $self = $error->stash('self'); |
2670
|
|
|
|
|
|
|
|
2671
|
|
|
|
|
|
|
# bless({...}, 'Venus::Path') |
2672
|
|
|
|
|
|
|
|
2673
|
|
|
|
|
|
|
=back |
2674
|
|
|
|
|
|
|
|
2675
|
|
|
|
|
|
|
=over 4 |
2676
|
|
|
|
|
|
|
|
2677
|
|
|
|
|
|
|
=item error: C |
2678
|
|
|
|
|
|
|
|
2679
|
|
|
|
|
|
|
This package may raise an error_on_open exception. |
2680
|
|
|
|
|
|
|
|
2681
|
|
|
|
|
|
|
B |
2682
|
|
|
|
|
|
|
|
2683
|
|
|
|
|
|
|
# given: synopsis; |
2684
|
|
|
|
|
|
|
|
2685
|
|
|
|
|
|
|
my $input = { |
2686
|
|
|
|
|
|
|
throw => 'error_on_open', |
2687
|
|
|
|
|
|
|
error => $!, |
2688
|
|
|
|
|
|
|
path => '/nowhere', |
2689
|
|
|
|
|
|
|
}; |
2690
|
|
|
|
|
|
|
|
2691
|
|
|
|
|
|
|
my $error = $path->catch('error', $input); |
2692
|
|
|
|
|
|
|
|
2693
|
|
|
|
|
|
|
# my $name = $error->name; |
2694
|
|
|
|
|
|
|
|
2695
|
|
|
|
|
|
|
# "on_open" |
2696
|
|
|
|
|
|
|
|
2697
|
|
|
|
|
|
|
# my $message = $error->render; |
2698
|
|
|
|
|
|
|
|
2699
|
|
|
|
|
|
|
# "Can't open \"/nowhere\": $!" |
2700
|
|
|
|
|
|
|
|
2701
|
|
|
|
|
|
|
# my $path = $error->stash('path'); |
2702
|
|
|
|
|
|
|
|
2703
|
|
|
|
|
|
|
# "/nowhere" |
2704
|
|
|
|
|
|
|
|
2705
|
|
|
|
|
|
|
=back |
2706
|
|
|
|
|
|
|
|
2707
|
|
|
|
|
|
|
=over 4 |
2708
|
|
|
|
|
|
|
|
2709
|
|
|
|
|
|
|
=item error: C |
2710
|
|
|
|
|
|
|
|
2711
|
|
|
|
|
|
|
This package may raise an error_on_read_binmode exception. |
2712
|
|
|
|
|
|
|
|
2713
|
|
|
|
|
|
|
B |
2714
|
|
|
|
|
|
|
|
2715
|
|
|
|
|
|
|
# given: synopsis; |
2716
|
|
|
|
|
|
|
|
2717
|
|
|
|
|
|
|
my $input = { |
2718
|
|
|
|
|
|
|
throw => 'error_on_read_binmode', |
2719
|
|
|
|
|
|
|
error => $!, |
2720
|
|
|
|
|
|
|
path => '/nowhere', |
2721
|
|
|
|
|
|
|
}; |
2722
|
|
|
|
|
|
|
|
2723
|
|
|
|
|
|
|
my $error = $path->catch('error', $input); |
2724
|
|
|
|
|
|
|
|
2725
|
|
|
|
|
|
|
# my $name = $error->name; |
2726
|
|
|
|
|
|
|
|
2727
|
|
|
|
|
|
|
# "on_read_binmode" |
2728
|
|
|
|
|
|
|
|
2729
|
|
|
|
|
|
|
# my $message = $error->render; |
2730
|
|
|
|
|
|
|
|
2731
|
|
|
|
|
|
|
# "Can't binmode \"/nowhere\": $!" |
2732
|
|
|
|
|
|
|
|
2733
|
|
|
|
|
|
|
# my $path = $error->stash('path'); |
2734
|
|
|
|
|
|
|
|
2735
|
|
|
|
|
|
|
# "/nowhere" |
2736
|
|
|
|
|
|
|
|
2737
|
|
|
|
|
|
|
=back |
2738
|
|
|
|
|
|
|
|
2739
|
|
|
|
|
|
|
=over 4 |
2740
|
|
|
|
|
|
|
|
2741
|
|
|
|
|
|
|
=item error: C |
2742
|
|
|
|
|
|
|
|
2743
|
|
|
|
|
|
|
This package may raise an error_on_read_error exception. |
2744
|
|
|
|
|
|
|
|
2745
|
|
|
|
|
|
|
B |
2746
|
|
|
|
|
|
|
|
2747
|
|
|
|
|
|
|
# given: synopsis; |
2748
|
|
|
|
|
|
|
|
2749
|
|
|
|
|
|
|
my $input = { |
2750
|
|
|
|
|
|
|
throw => 'error_on_read_error', |
2751
|
|
|
|
|
|
|
error => $!, |
2752
|
|
|
|
|
|
|
path => '/nowhere', |
2753
|
|
|
|
|
|
|
}; |
2754
|
|
|
|
|
|
|
|
2755
|
|
|
|
|
|
|
my $error = $path->catch('error', $input); |
2756
|
|
|
|
|
|
|
|
2757
|
|
|
|
|
|
|
# my $name = $error->name; |
2758
|
|
|
|
|
|
|
|
2759
|
|
|
|
|
|
|
# "on_read_error" |
2760
|
|
|
|
|
|
|
|
2761
|
|
|
|
|
|
|
# my $message = $error->render; |
2762
|
|
|
|
|
|
|
|
2763
|
|
|
|
|
|
|
# "Can't read from file \"/nowhere\": $!" |
2764
|
|
|
|
|
|
|
|
2765
|
|
|
|
|
|
|
# my $path = $error->stash('path'); |
2766
|
|
|
|
|
|
|
|
2767
|
|
|
|
|
|
|
# "/nowhere" |
2768
|
|
|
|
|
|
|
|
2769
|
|
|
|
|
|
|
=back |
2770
|
|
|
|
|
|
|
|
2771
|
|
|
|
|
|
|
=over 4 |
2772
|
|
|
|
|
|
|
|
2773
|
|
|
|
|
|
|
=item error: C |
2774
|
|
|
|
|
|
|
|
2775
|
|
|
|
|
|
|
This package may raise an error_on_read_open exception. |
2776
|
|
|
|
|
|
|
|
2777
|
|
|
|
|
|
|
B |
2778
|
|
|
|
|
|
|
|
2779
|
|
|
|
|
|
|
# given: synopsis; |
2780
|
|
|
|
|
|
|
|
2781
|
|
|
|
|
|
|
my $input = { |
2782
|
|
|
|
|
|
|
throw => 'error_on_read_open', |
2783
|
|
|
|
|
|
|
error => $!, |
2784
|
|
|
|
|
|
|
path => '/nowhere', |
2785
|
|
|
|
|
|
|
}; |
2786
|
|
|
|
|
|
|
|
2787
|
|
|
|
|
|
|
my $error = $path->catch('error', $input); |
2788
|
|
|
|
|
|
|
|
2789
|
|
|
|
|
|
|
# my $name = $error->name; |
2790
|
|
|
|
|
|
|
|
2791
|
|
|
|
|
|
|
# "on_read_open" |
2792
|
|
|
|
|
|
|
|
2793
|
|
|
|
|
|
|
# my $message = $error->render; |
2794
|
|
|
|
|
|
|
|
2795
|
|
|
|
|
|
|
# "Can't read \"/nowhere\": $!" |
2796
|
|
|
|
|
|
|
|
2797
|
|
|
|
|
|
|
# my $path = $error->stash('path'); |
2798
|
|
|
|
|
|
|
|
2799
|
|
|
|
|
|
|
# "/nowhere" |
2800
|
|
|
|
|
|
|
|
2801
|
|
|
|
|
|
|
=back |
2802
|
|
|
|
|
|
|
|
2803
|
|
|
|
|
|
|
=over 4 |
2804
|
|
|
|
|
|
|
|
2805
|
|
|
|
|
|
|
=item error: C |
2806
|
|
|
|
|
|
|
|
2807
|
|
|
|
|
|
|
This package may raise an error_on_rmdir exception. |
2808
|
|
|
|
|
|
|
|
2809
|
|
|
|
|
|
|
B |
2810
|
|
|
|
|
|
|
|
2811
|
|
|
|
|
|
|
# given: synopsis; |
2812
|
|
|
|
|
|
|
|
2813
|
|
|
|
|
|
|
my $input = { |
2814
|
|
|
|
|
|
|
throw => 'error_on_rmdir', |
2815
|
|
|
|
|
|
|
error => $!, |
2816
|
|
|
|
|
|
|
path => '/nowhere', |
2817
|
|
|
|
|
|
|
}; |
2818
|
|
|
|
|
|
|
|
2819
|
|
|
|
|
|
|
my $error = $path->catch('error', $input); |
2820
|
|
|
|
|
|
|
|
2821
|
|
|
|
|
|
|
# my $name = $error->name; |
2822
|
|
|
|
|
|
|
|
2823
|
|
|
|
|
|
|
# "on_rmdir" |
2824
|
|
|
|
|
|
|
|
2825
|
|
|
|
|
|
|
# my $message = $error->render; |
2826
|
|
|
|
|
|
|
|
2827
|
|
|
|
|
|
|
# "Can't rmdir \"/nowhere\": $!" |
2828
|
|
|
|
|
|
|
|
2829
|
|
|
|
|
|
|
# my $path = $error->stash('path'); |
2830
|
|
|
|
|
|
|
|
2831
|
|
|
|
|
|
|
# "/nowhere" |
2832
|
|
|
|
|
|
|
|
2833
|
|
|
|
|
|
|
=back |
2834
|
|
|
|
|
|
|
|
2835
|
|
|
|
|
|
|
=over 4 |
2836
|
|
|
|
|
|
|
|
2837
|
|
|
|
|
|
|
=item error: C |
2838
|
|
|
|
|
|
|
|
2839
|
|
|
|
|
|
|
This package may raise an error_on_write_binmode exception. |
2840
|
|
|
|
|
|
|
|
2841
|
|
|
|
|
|
|
B |
2842
|
|
|
|
|
|
|
|
2843
|
|
|
|
|
|
|
# given: synopsis; |
2844
|
|
|
|
|
|
|
|
2845
|
|
|
|
|
|
|
my $input = { |
2846
|
|
|
|
|
|
|
throw => 'error_on_write_binmode', |
2847
|
|
|
|
|
|
|
error => $!, |
2848
|
|
|
|
|
|
|
path => '/nowhere', |
2849
|
|
|
|
|
|
|
binmode => ':utf8', |
2850
|
|
|
|
|
|
|
}; |
2851
|
|
|
|
|
|
|
|
2852
|
|
|
|
|
|
|
my $error = $path->catch('error', $input); |
2853
|
|
|
|
|
|
|
|
2854
|
|
|
|
|
|
|
# my $name = $error->name; |
2855
|
|
|
|
|
|
|
|
2856
|
|
|
|
|
|
|
# "on_write_binmode" |
2857
|
|
|
|
|
|
|
|
2858
|
|
|
|
|
|
|
# my $message = $error->render; |
2859
|
|
|
|
|
|
|
|
2860
|
|
|
|
|
|
|
# "Can't binmode \"/nowhere\": $!" |
2861
|
|
|
|
|
|
|
|
2862
|
|
|
|
|
|
|
# my $binmode = $error->stash('binmode'); |
2863
|
|
|
|
|
|
|
|
2864
|
|
|
|
|
|
|
# ":utf8" |
2865
|
|
|
|
|
|
|
|
2866
|
|
|
|
|
|
|
# my $path = $error->stash('path'); |
2867
|
|
|
|
|
|
|
|
2868
|
|
|
|
|
|
|
# "/nowhere" |
2869
|
|
|
|
|
|
|
|
2870
|
|
|
|
|
|
|
=back |
2871
|
|
|
|
|
|
|
|
2872
|
|
|
|
|
|
|
=over 4 |
2873
|
|
|
|
|
|
|
|
2874
|
|
|
|
|
|
|
=item error: C |
2875
|
|
|
|
|
|
|
|
2876
|
|
|
|
|
|
|
This package may raise an error_on_write_error exception. |
2877
|
|
|
|
|
|
|
|
2878
|
|
|
|
|
|
|
B |
2879
|
|
|
|
|
|
|
|
2880
|
|
|
|
|
|
|
# given: synopsis; |
2881
|
|
|
|
|
|
|
|
2882
|
|
|
|
|
|
|
my $input = { |
2883
|
|
|
|
|
|
|
throw => 'error_on_write_error', |
2884
|
|
|
|
|
|
|
error => $!, |
2885
|
|
|
|
|
|
|
path => '/nowhere', |
2886
|
|
|
|
|
|
|
}; |
2887
|
|
|
|
|
|
|
|
2888
|
|
|
|
|
|
|
my $error = $path->catch('error', $input); |
2889
|
|
|
|
|
|
|
|
2890
|
|
|
|
|
|
|
# my $name = $error->name; |
2891
|
|
|
|
|
|
|
|
2892
|
|
|
|
|
|
|
# "on_write_error" |
2893
|
|
|
|
|
|
|
|
2894
|
|
|
|
|
|
|
# my $message = $error->render; |
2895
|
|
|
|
|
|
|
|
2896
|
|
|
|
|
|
|
# "Can't write to file \"/nowhere\": $!" |
2897
|
|
|
|
|
|
|
|
2898
|
|
|
|
|
|
|
# my $path = $error->stash('path'); |
2899
|
|
|
|
|
|
|
|
2900
|
|
|
|
|
|
|
# "/nowhere" |
2901
|
|
|
|
|
|
|
|
2902
|
|
|
|
|
|
|
=back |
2903
|
|
|
|
|
|
|
|
2904
|
|
|
|
|
|
|
=over 4 |
2905
|
|
|
|
|
|
|
|
2906
|
|
|
|
|
|
|
=item error: C |
2907
|
|
|
|
|
|
|
|
2908
|
|
|
|
|
|
|
This package may raise an error_on_write_open exception. |
2909
|
|
|
|
|
|
|
|
2910
|
|
|
|
|
|
|
B |
2911
|
|
|
|
|
|
|
|
2912
|
|
|
|
|
|
|
# given: synopsis; |
2913
|
|
|
|
|
|
|
|
2914
|
|
|
|
|
|
|
my $input = { |
2915
|
|
|
|
|
|
|
throw => 'error_on_write_open', |
2916
|
|
|
|
|
|
|
error => $!, |
2917
|
|
|
|
|
|
|
path => '/nowhere', |
2918
|
|
|
|
|
|
|
}; |
2919
|
|
|
|
|
|
|
|
2920
|
|
|
|
|
|
|
my $error = $path->catch('error', $input); |
2921
|
|
|
|
|
|
|
|
2922
|
|
|
|
|
|
|
# my $name = $error->name; |
2923
|
|
|
|
|
|
|
|
2924
|
|
|
|
|
|
|
# "on_write_open" |
2925
|
|
|
|
|
|
|
|
2926
|
|
|
|
|
|
|
# my $message = $error->render; |
2927
|
|
|
|
|
|
|
|
2928
|
|
|
|
|
|
|
# "Can't write \"/nowhere\": $!" |
2929
|
|
|
|
|
|
|
|
2930
|
|
|
|
|
|
|
# my $path = $error->stash('path'); |
2931
|
|
|
|
|
|
|
|
2932
|
|
|
|
|
|
|
# "/nowhere" |
2933
|
|
|
|
|
|
|
|
2934
|
|
|
|
|
|
|
=back |
2935
|
|
|
|
|
|
|
|
2936
|
|
|
|
|
|
|
=over 4 |
2937
|
|
|
|
|
|
|
|
2938
|
|
|
|
|
|
|
=item error: C |
2939
|
|
|
|
|
|
|
|
2940
|
|
|
|
|
|
|
This package may raise an error_on_unlink exception. |
2941
|
|
|
|
|
|
|
|
2942
|
|
|
|
|
|
|
B |
2943
|
|
|
|
|
|
|
|
2944
|
|
|
|
|
|
|
# given: synopsis; |
2945
|
|
|
|
|
|
|
|
2946
|
|
|
|
|
|
|
my $input = { |
2947
|
|
|
|
|
|
|
throw => 'error_on_unlink', |
2948
|
|
|
|
|
|
|
error => $!, |
2949
|
|
|
|
|
|
|
path => '/nowhere', |
2950
|
|
|
|
|
|
|
}; |
2951
|
|
|
|
|
|
|
|
2952
|
|
|
|
|
|
|
my $error = $path->catch('error', $input); |
2953
|
|
|
|
|
|
|
|
2954
|
|
|
|
|
|
|
# my $name = $error->name; |
2955
|
|
|
|
|
|
|
|
2956
|
|
|
|
|
|
|
# "on_unlink" |
2957
|
|
|
|
|
|
|
|
2958
|
|
|
|
|
|
|
# my $message = $error->render; |
2959
|
|
|
|
|
|
|
|
2960
|
|
|
|
|
|
|
# "Can't unlink \"/nowhere\": $!" |
2961
|
|
|
|
|
|
|
|
2962
|
|
|
|
|
|
|
# my $path = $error->stash('path'); |
2963
|
|
|
|
|
|
|
|
2964
|
|
|
|
|
|
|
# "/nowhere" |
2965
|
|
|
|
|
|
|
|
2966
|
|
|
|
|
|
|
=back |
2967
|
|
|
|
|
|
|
|
2968
|
|
|
|
|
|
|
=head1 OPERATORS |
2969
|
|
|
|
|
|
|
|
2970
|
|
|
|
|
|
|
This package overloads the following operators: |
2971
|
|
|
|
|
|
|
|
2972
|
|
|
|
|
|
|
=cut |
2973
|
|
|
|
|
|
|
|
2974
|
|
|
|
|
|
|
=over 4 |
2975
|
|
|
|
|
|
|
|
2976
|
|
|
|
|
|
|
=item operation: C<(.)> |
2977
|
|
|
|
|
|
|
|
2978
|
|
|
|
|
|
|
This package overloads the C<.> operator. |
2979
|
|
|
|
|
|
|
|
2980
|
|
|
|
|
|
|
B |
2981
|
|
|
|
|
|
|
|
2982
|
|
|
|
|
|
|
# given: synopsis; |
2983
|
|
|
|
|
|
|
|
2984
|
|
|
|
|
|
|
my $result = $path . '/earth'; |
2985
|
|
|
|
|
|
|
|
2986
|
|
|
|
|
|
|
# "t/data/planets/earth" |
2987
|
|
|
|
|
|
|
|
2988
|
|
|
|
|
|
|
=back |
2989
|
|
|
|
|
|
|
|
2990
|
|
|
|
|
|
|
=over 4 |
2991
|
|
|
|
|
|
|
|
2992
|
|
|
|
|
|
|
=item operation: C<(eq)> |
2993
|
|
|
|
|
|
|
|
2994
|
|
|
|
|
|
|
This package overloads the C operator. |
2995
|
|
|
|
|
|
|
|
2996
|
|
|
|
|
|
|
B |
2997
|
|
|
|
|
|
|
|
2998
|
|
|
|
|
|
|
# given: synopsis; |
2999
|
|
|
|
|
|
|
|
3000
|
|
|
|
|
|
|
my $result = $path eq 't/data/planets'; |
3001
|
|
|
|
|
|
|
|
3002
|
|
|
|
|
|
|
# 1 |
3003
|
|
|
|
|
|
|
|
3004
|
|
|
|
|
|
|
=back |
3005
|
|
|
|
|
|
|
|
3006
|
|
|
|
|
|
|
=over 4 |
3007
|
|
|
|
|
|
|
|
3008
|
|
|
|
|
|
|
=item operation: C<(ne)> |
3009
|
|
|
|
|
|
|
|
3010
|
|
|
|
|
|
|
This package overloads the C operator. |
3011
|
|
|
|
|
|
|
|
3012
|
|
|
|
|
|
|
B |
3013
|
|
|
|
|
|
|
|
3014
|
|
|
|
|
|
|
# given: synopsis; |
3015
|
|
|
|
|
|
|
|
3016
|
|
|
|
|
|
|
my $result = $path ne 't/data/planets/'; |
3017
|
|
|
|
|
|
|
|
3018
|
|
|
|
|
|
|
# 1 |
3019
|
|
|
|
|
|
|
|
3020
|
|
|
|
|
|
|
=back |
3021
|
|
|
|
|
|
|
|
3022
|
|
|
|
|
|
|
=over 4 |
3023
|
|
|
|
|
|
|
|
3024
|
|
|
|
|
|
|
=item operation: C<(qr)> |
3025
|
|
|
|
|
|
|
|
3026
|
|
|
|
|
|
|
This package overloads the C operator. |
3027
|
|
|
|
|
|
|
|
3028
|
|
|
|
|
|
|
B |
3029
|
|
|
|
|
|
|
|
3030
|
|
|
|
|
|
|
# given: synopsis; |
3031
|
|
|
|
|
|
|
|
3032
|
|
|
|
|
|
|
my $result = 't/data/planets' =~ $path; |
3033
|
|
|
|
|
|
|
|
3034
|
|
|
|
|
|
|
# 1 |
3035
|
|
|
|
|
|
|
|
3036
|
|
|
|
|
|
|
=back |
3037
|
|
|
|
|
|
|
|
3038
|
|
|
|
|
|
|
=over 4 |
3039
|
|
|
|
|
|
|
|
3040
|
|
|
|
|
|
|
=item operation: C<("")> |
3041
|
|
|
|
|
|
|
|
3042
|
|
|
|
|
|
|
This package overloads the C<""> operator. |
3043
|
|
|
|
|
|
|
|
3044
|
|
|
|
|
|
|
B |
3045
|
|
|
|
|
|
|
|
3046
|
|
|
|
|
|
|
# given: synopsis; |
3047
|
|
|
|
|
|
|
|
3048
|
|
|
|
|
|
|
my $result = "$path"; |
3049
|
|
|
|
|
|
|
|
3050
|
|
|
|
|
|
|
# "t/data/planets" |
3051
|
|
|
|
|
|
|
|
3052
|
|
|
|
|
|
|
B |
3053
|
|
|
|
|
|
|
|
3054
|
|
|
|
|
|
|
# given: synopsis; |
3055
|
|
|
|
|
|
|
|
3056
|
|
|
|
|
|
|
my $mercury = $path->child('mercury'); |
3057
|
|
|
|
|
|
|
|
3058
|
|
|
|
|
|
|
my $result = "$path, $path"; |
3059
|
|
|
|
|
|
|
|
3060
|
|
|
|
|
|
|
# "t/data/planets, t/data/planets" |
3061
|
|
|
|
|
|
|
|
3062
|
|
|
|
|
|
|
=back |
3063
|
|
|
|
|
|
|
|
3064
|
|
|
|
|
|
|
=over 4 |
3065
|
|
|
|
|
|
|
|
3066
|
|
|
|
|
|
|
=item operation: C<(~~)> |
3067
|
|
|
|
|
|
|
|
3068
|
|
|
|
|
|
|
This package overloads the C<~~> operator. |
3069
|
|
|
|
|
|
|
|
3070
|
|
|
|
|
|
|
B |
3071
|
|
|
|
|
|
|
|
3072
|
|
|
|
|
|
|
# given: synopsis; |
3073
|
|
|
|
|
|
|
|
3074
|
|
|
|
|
|
|
my $result = $path ~~ 't/data/planets'; |
3075
|
|
|
|
|
|
|
|
3076
|
|
|
|
|
|
|
# 1 |
3077
|
|
|
|
|
|
|
|
3078
|
|
|
|
|
|
|
=back |
3079
|
|
|
|
|
|
|
|
3080
|
|
|
|
|
|
|
=head1 AUTHORS |
3081
|
|
|
|
|
|
|
|
3082
|
|
|
|
|
|
|
Awncorp, C |
3083
|
|
|
|
|
|
|
|
3084
|
|
|
|
|
|
|
=cut |
3085
|
|
|
|
|
|
|
|
3086
|
|
|
|
|
|
|
=head1 LICENSE |
3087
|
|
|
|
|
|
|
|
3088
|
|
|
|
|
|
|
Copyright (C) 2000, Al Newkirk. |
3089
|
|
|
|
|
|
|
|
3090
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
3091
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
3092
|
|
|
|
|
|
|
|
3093
|
|
|
|
|
|
|
=cut |