line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
|
|
|
|
|
|
package Path::Class::File; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
$VERSION = '0.17'; |
5
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
6
|
1
|
|
|
1
|
|
517
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
31
|
|
7
|
1
|
|
|
1
|
|
7
|
use Path::Class::Dir; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
8
|
1
|
|
|
1
|
|
5
|
use Path::Class::Entity; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
94
|
|
9
|
|
|
|
|
|
|
use base qw(Path::Class::Entity); |
10
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
529
|
|
11
|
|
|
|
|
|
|
use IO::File (); |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
0
|
1
|
|
sub new { |
14
|
0
|
|
|
|
|
|
my $self = shift->SUPER::new; |
15
|
0
|
|
|
|
|
|
my $file = pop(); |
16
|
|
|
|
|
|
|
my @dirs = @_; |
17
|
0
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my ($volume, $dirs, $base) = $self->_spec->splitpath($file); |
19
|
0
|
0
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
if (length $dirs) { |
21
|
|
|
|
|
|
|
push @dirs, $self->_spec->catpath($volume, $dirs, ''); |
22
|
|
|
|
|
|
|
} |
23
|
0
|
0
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
$self->{dir} = @dirs ? Path::Class::Dir->new(@dirs) : undef; |
25
|
|
|
|
|
|
|
$self->{file} = $base; |
26
|
0
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
1
|
|
sub as_foreign { |
31
|
0
|
|
|
|
|
|
my ($self, $type) = @_; |
32
|
0
|
|
|
|
|
|
local $Path::Class::Foreign = $self->_spec_class($type); |
33
|
0
|
0
|
|
|
|
|
my $foreign = ref($self)->SUPER::new; |
34
|
0
|
|
|
|
|
|
$foreign->{dir} = $self->{dir}->as_foreign($type) if defined $self->{dir}; |
35
|
0
|
|
|
|
|
|
$foreign->{file} = $self->{file}; |
36
|
|
|
|
|
|
|
return $foreign; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
1
|
|
sub stringify { |
40
|
0
|
0
|
|
|
|
|
my $self = shift; |
41
|
0
|
|
|
|
|
|
return $self->{file} unless defined $self->{dir}; |
42
|
|
|
|
|
|
|
return $self->_spec->catfile($self->{dir}->stringify, $self->{file}); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
1
|
|
sub dir { |
46
|
0
|
0
|
|
|
|
|
my $self = shift; |
47
|
0
|
|
|
|
|
|
return $self->{dir} if defined $self->{dir}; |
48
|
|
|
|
|
|
|
return Path::Class::Dir->new($self->_spec->curdir); |
49
|
1
|
|
|
1
|
|
446
|
} |
50
|
|
|
|
|
|
|
BEGIN { *parent = \&dir; } |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
0
|
1
|
|
sub volume { |
53
|
0
|
0
|
|
|
|
|
my $self = shift; |
54
|
0
|
|
|
|
|
|
return '' unless defined $self->{dir}; |
55
|
|
|
|
|
|
|
return $self->{dir}->volume; |
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
0
|
1
|
|
|
58
|
0
|
|
|
0
|
1
|
|
sub basename { shift->{file} } |
59
|
|
|
|
|
|
|
sub open { IO::File->new(@_) } |
60
|
0
|
0
|
|
0
|
1
|
|
|
61
|
0
|
0
|
|
0
|
1
|
|
sub openr { $_[0]->open('r') or die "Can't read $_[0]: $!" } |
62
|
|
|
|
|
|
|
sub openw { $_[0]->open('w') or die "Can't write $_[0]: $!" } |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
0
|
1
|
|
sub touch { |
65
|
0
|
0
|
|
|
|
|
my $self = shift; |
66
|
0
|
|
|
|
|
|
if (-e $self) { |
67
|
0
|
|
|
|
|
|
my $now = time(); |
68
|
|
|
|
|
|
|
utime $now, $now, $self; |
69
|
0
|
|
|
|
|
|
} else { |
70
|
|
|
|
|
|
|
$self->openw; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
0
|
1
|
|
sub slurp { |
75
|
0
|
|
|
|
|
|
my ($self, %args) = @_; |
76
|
|
|
|
|
|
|
my $fh = $self->openr; |
77
|
0
|
0
|
0
|
|
|
|
|
78
|
0
|
|
|
|
|
|
if ($args{chomped} or $args{chomp}) { |
79
|
0
|
0
|
|
|
|
|
chomp( my @data = <$fh> ); |
80
|
|
|
|
|
|
|
return wantarray ? @data : join '', @data; |
81
|
|
|
|
|
|
|
} |
82
|
0
|
0
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
local $/ unless wantarray; |
84
|
|
|
|
|
|
|
return <$fh>; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
0
|
1
|
|
sub remove { |
88
|
0
|
0
|
|
|
|
|
my $file = shift->stringify; |
89
|
0
|
|
|
|
|
|
return unlink $file unless -e $file; # Sets $! correctly |
90
|
0
|
|
|
|
|
|
1 while unlink $file; |
91
|
|
|
|
|
|
|
return not -e $file; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
__END__ |