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