line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DMOSS::File; |
2
|
|
|
|
|
|
|
# ABSTRACT: DMOSS file object |
3
|
|
|
|
|
|
|
$DMOSS::File::VERSION = '0.01_2'; |
4
|
3
|
|
|
3
|
|
28406
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
113
|
|
5
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
102
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
16
|
use File::Basename (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
57
|
|
8
|
3
|
|
|
3
|
|
3024
|
use File::Slurp qw/slurp/; |
|
3
|
|
|
|
|
51920
|
|
|
3
|
|
|
|
|
1443
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
1
|
|
|
1
|
1
|
652
|
my ($class, $basedir, $fullpath) = @_; |
12
|
1
|
|
|
|
|
4
|
my $self = bless({}, $class); |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
7
|
$self->fullpath($fullpath); |
15
|
1
|
50
|
|
|
|
3
|
$self->basename(File::Basename::basename($fullpath)) if $fullpath; |
16
|
1
|
50
|
|
|
|
6
|
$self->dirname(File::Basename::dirname($fullpath)) if $fullpath; |
17
|
1
|
|
|
|
|
2
|
my $path = $fullpath; |
18
|
1
|
50
|
|
|
|
4
|
$path =~ s/$basedir//g if $path; |
19
|
1
|
50
|
|
|
|
3
|
$path =~ s/^\/+//g if $path; |
20
|
1
|
|
|
|
|
2
|
$self->{path} = $path; |
21
|
1
|
50
|
33
|
|
|
6
|
$self->{isfile} = 1 unless ($fullpath and -d $fullpath); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#$self->content(slurp $fullpath) if -e $fullpath; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
4
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub basename { |
29
|
0
|
|
|
0
|
1
|
0
|
my ($self, $basename) = @_; |
30
|
0
|
0
|
|
|
|
0
|
$self->{basename} = $basename if $basename; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
return $self->{basename}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub fullpath { |
36
|
1
|
|
|
1
|
1
|
2
|
my ($self, $fullpath) = @_; |
37
|
1
|
50
|
|
|
|
5
|
$self->{fullpath} = $fullpath if $fullpath; |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
8
|
return $self->{fullpath}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub dirname { |
43
|
0
|
|
|
0
|
1
|
|
my ($self, $dirname) = @_; |
44
|
0
|
0
|
|
|
|
|
$self->{dirname} = $dirname if $dirname; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return $self->{dirname}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub path { |
50
|
0
|
|
|
0
|
1
|
|
my ($self, $path) = @_; |
51
|
0
|
0
|
|
|
|
|
$self->{path} = $path if $path; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
return $self->{path}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub type { |
57
|
0
|
|
|
0
|
1
|
|
my ($self, $type) = @_; |
58
|
0
|
0
|
|
|
|
|
$self->{type} = $type if $type; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return $self->{type}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub content { |
64
|
0
|
|
|
0
|
1
|
|
my ($self, $content) = @_; |
65
|
0
|
0
|
|
|
|
|
$self->{content} = $content if $content; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
return $self->{content}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub isfile { |
71
|
0
|
|
|
0
|
1
|
|
my ($self, $isfile) = @_; |
72
|
0
|
0
|
|
|
|
|
$self->{isfile} = $isfile if $isfile; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return $self->{isfile}; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |