| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Kwiki::WebFile; |
|
2
|
1
|
|
|
1
|
|
77
|
use Kwiki::Base -Base; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use Spoon::Base 'conf'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our @EXPORT = qw(conf); |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
field path => []; |
|
8
|
|
|
|
|
|
|
field files => []; |
|
9
|
|
|
|
|
|
|
const default_path_method => 'default_path'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub init { |
|
12
|
|
|
|
|
|
|
my $method = $self->default_path_method; |
|
13
|
|
|
|
|
|
|
$self->add_path(@{$self->$method}); |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub add_file { |
|
17
|
|
|
|
|
|
|
my $file = shift |
|
18
|
|
|
|
|
|
|
or return; |
|
19
|
|
|
|
|
|
|
my $file_path = ''; |
|
20
|
|
|
|
|
|
|
for (@{$self->path}) { |
|
21
|
|
|
|
|
|
|
$file_path = "$_/$file", last |
|
22
|
|
|
|
|
|
|
if -f "$_/$file"; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
my $files = $self->files; |
|
25
|
|
|
|
|
|
|
@$files = grep { not /\/$file$/ } @$files; |
|
26
|
|
|
|
|
|
|
push @$files, $file_path; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub files_which_exist { |
|
30
|
|
|
|
|
|
|
grep {io->file($_)->exists} @{$self->files}; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub add_path { |
|
34
|
|
|
|
|
|
|
unshift @{$self->path}, @_; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub clear_files { |
|
38
|
|
|
|
|
|
|
$self->files([]); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__DATA__ |