line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2003-2021 by [Mark Overmeer]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.02. |
5
|
|
|
|
|
|
|
# This code is part of perl distribution OODoc. It is licensed under the |
6
|
|
|
|
|
|
|
# same terms as Perl itself: https://spdx.org/licenses/Artistic-2.0.html |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package OODoc::Manifest; |
9
|
2
|
|
|
2
|
|
14
|
use vars '$VERSION'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
119
|
|
10
|
|
|
|
|
|
|
$VERSION = '2.02'; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
22
|
use base 'OODoc::Object'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
183
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
34
|
|
15
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
59
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
13
|
use IO::File; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
317
|
|
18
|
2
|
|
|
2
|
|
14
|
use File::Basename 'dirname'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
193
|
|
19
|
2
|
|
|
2
|
|
13
|
use Log::Report 'oodoc'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
12
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
|
600
|
use overload '@{}' => sub { [ shift->files ] }; |
|
2
|
|
|
0
|
|
4
|
|
|
2
|
|
|
|
|
18
|
|
|
0
|
|
|
|
|
0
|
|
23
|
2
|
|
|
2
|
|
146
|
use overload bool => sub {1}; |
|
2
|
|
|
0
|
|
4
|
|
|
2
|
|
|
|
|
21
|
|
|
0
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#------------------------------------------- |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub init($) |
29
|
0
|
|
|
0
|
0
|
|
{ my ($self, $args) = @_; |
30
|
0
|
0
|
|
|
|
|
$self->SUPER::init($args) or return; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $filename = $self->{OM_filename} = delete $args->{filename}; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$self->{O_files} = {}; |
35
|
0
|
0
|
0
|
|
|
|
$self->read if defined $filename && -e $filename; |
36
|
0
|
|
|
|
|
|
$self->modified(0); |
37
|
0
|
|
|
|
|
|
$self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#------------------------------------------- |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
1
|
|
sub filename() {shift->{OM_filename}} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#------------------------------------------- |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
0
|
1
|
|
sub files() { keys %{shift->{O_files}} } |
|
0
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#------------------------------------------- |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub add($) |
54
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
55
|
0
|
|
|
|
|
|
while(@_) |
56
|
0
|
|
|
|
|
|
{ my $add = $self->relative(shift); |
57
|
0
|
0
|
|
|
|
|
$self->modified(1) unless exists $self->{O_file}{$add}; |
58
|
0
|
|
|
|
|
|
$self->{O_files}{$add}++; |
59
|
|
|
|
|
|
|
} |
60
|
0
|
|
|
|
|
|
$self; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#------------------------------------------- |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub read() |
67
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
68
|
0
|
|
|
|
|
|
my $filename = $self->filename; |
69
|
0
|
0
|
|
|
|
|
my $file = IO::File->new($filename, "r") |
70
|
|
|
|
|
|
|
or fault __x"cannot read manifest file {file}", file => $filename; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my @dist = $file->getlines; |
73
|
0
|
|
|
|
|
|
$file->close; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
s/\s+.*\n?$// for @dist; |
76
|
0
|
|
|
|
|
|
$self->{O_files}{$_}++ foreach @dist; |
77
|
0
|
|
|
|
|
|
$self; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
#------------------------------------------- |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub modified(;$) |
84
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
85
|
0
|
0
|
|
|
|
|
@_ ? $self->{OM_modified} = @_ : $self->{OM_modified}; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
#------------------------------------------- |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub write() |
92
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
93
|
0
|
0
|
|
|
|
|
return unless $self->modified; |
94
|
0
|
|
0
|
|
|
|
my $filename = $self->filename || return $self; |
95
|
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
|
my $file = IO::File->new($filename, "w") |
97
|
|
|
|
|
|
|
or fault __x"cannot write manifest {file}", file => $filename; |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
$file->print($_, "\n") foreach sort $self->files; |
100
|
0
|
|
|
|
|
|
$file->close; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
$self->modified(0); |
103
|
0
|
|
|
|
|
|
$self; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
0
|
|
|
sub DESTROY() { shift->write } |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
#------------------------------------------- |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub relative($) |
112
|
0
|
|
|
0
|
1
|
|
{ my ($self, $filename) = @_; |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
my $dir = dirname $self->filename; |
115
|
0
|
0
|
|
|
|
|
return $filename if $dir eq '.'; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# normalize path for windows |
118
|
0
|
|
|
|
|
|
s!\\!/!g for $filename, $dir; |
119
|
|
|
|
|
|
|
|
120
|
0
|
0
|
|
|
|
|
if(substr($filename, 0, length($dir)+1) eq "$dir/") |
121
|
0
|
|
|
|
|
|
{ substr $filename, 0, length($dir)+1, ''; |
122
|
0
|
|
|
|
|
|
return $filename; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
warn "WARNING: MANIFEST file ".$self->filename |
126
|
|
|
|
|
|
|
. " lists filename outside (sub)directory: $filename\n"; |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
$filename; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
#------------------------------------------- |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |