line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PITA::XML::File; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# A PITA::XML class that represents an file resource for a Guest |
4
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
172
|
use 5.006; |
|
10
|
|
|
|
|
30
|
|
|
10
|
|
|
|
|
373
|
|
6
|
10
|
|
|
10
|
|
48
|
use strict; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
340
|
|
7
|
10
|
|
|
10
|
|
10435
|
use Data::Digest (); |
|
10
|
|
|
|
|
35302
|
|
|
10
|
|
|
|
|
257
|
|
8
|
10
|
|
|
10
|
|
69
|
use Params::Util qw{ _INSTANCE _STRING }; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
482
|
|
9
|
10
|
|
|
10
|
|
59
|
use PITA::XML::Storable (); |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
185
|
|
10
|
|
|
|
|
|
|
|
11
|
10
|
|
|
10
|
|
52
|
use vars qw{$VERSION @ISA}; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
587
|
|
12
|
|
|
|
|
|
|
BEGIN { |
13
|
10
|
|
|
10
|
|
34
|
$VERSION = '0.52'; |
14
|
10
|
|
|
|
|
3354
|
@ISA = 'PITA::XML::Storable'; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
0
|
0
|
sub xml_entity { 'file' } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
##################################################################### |
25
|
|
|
|
|
|
|
# Constructor and Accessors |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
19
|
|
|
19
|
0
|
7832
|
my $class = shift; |
29
|
19
|
|
|
|
|
101
|
my $self = bless { @_ }, $class; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Check the object |
32
|
19
|
|
|
|
|
67
|
$self->_init; |
33
|
|
|
|
|
|
|
|
34
|
10
|
|
|
|
|
54
|
$self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Format-check the parameters |
38
|
|
|
|
|
|
|
sub _init { |
39
|
26
|
|
|
26
|
|
51
|
my $self = shift; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# The file name is required |
42
|
26
|
100
|
|
|
|
81
|
unless ( _STRING($self->filename) ) { |
43
|
4
|
|
|
|
|
721
|
Carp::croak('Missing or invalid filename'); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# The resource descriptor is optional |
47
|
22
|
100
|
|
|
|
79
|
if ( exists $self->{resource} ) { |
48
|
10
|
100
|
|
|
|
36
|
unless ( _STRING($self->{resource}) ) { |
49
|
2
|
|
|
|
|
251
|
Carp::croak('Cannot provide a null resource type'); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# The digest is optional |
54
|
20
|
50
|
|
|
|
71
|
if ( exists $self->{digest} ) { |
55
|
20
|
|
|
|
|
40
|
eval { $self->{digest} = $self->_DIGEST($self->{digest}) }; |
|
20
|
|
|
|
|
81
|
|
56
|
20
|
100
|
|
|
|
1426
|
Carp::croak("Missing or invalid digest") if $@; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
17
|
|
|
|
|
39
|
$self; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub filename { |
63
|
39
|
|
|
39
|
0
|
801
|
$_[0]->{filename}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub resource { |
67
|
7
|
|
|
7
|
0
|
43
|
$_[0]->{resource}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub digest { |
71
|
18
|
|
|
18
|
0
|
151
|
$_[0]->{digest}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
##################################################################### |
79
|
|
|
|
|
|
|
# Main Methods |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
##################################################################### |
87
|
|
|
|
|
|
|
# Support Methods |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _DIGEST { |
90
|
20
|
50
|
|
20
|
|
222
|
_INSTANCE($_[1], 'Data::Digest') ? $_[1] : Data::Digest->new($_[1]); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |