line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::FileBag::Index; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '1.14'; |
4
|
|
|
|
|
|
|
|
5
|
12
|
|
|
12
|
|
78762
|
use Catmandu::Sane; |
|
12
|
|
|
|
|
195419
|
|
|
12
|
|
|
|
|
95
|
|
6
|
12
|
|
|
12
|
|
2763
|
use Moo::Role; |
|
12
|
|
|
|
|
29
|
|
|
12
|
|
|
|
|
78
|
|
7
|
12
|
|
|
12
|
|
9689
|
use IO::String; |
|
12
|
|
|
|
|
26220
|
|
|
12
|
|
|
|
|
394
|
|
8
|
12
|
|
|
12
|
|
87
|
use utf8; |
|
12
|
|
|
|
|
28
|
|
|
12
|
|
|
|
|
61
|
|
9
|
12
|
|
|
12
|
|
345
|
use Catmandu::Util qw(:check); |
|
12
|
|
|
|
|
27
|
|
|
12
|
|
|
|
|
3206
|
|
10
|
12
|
|
|
12
|
|
91
|
use namespace::clean; |
|
12
|
|
|
|
|
26
|
|
|
12
|
|
|
|
|
93
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub files { |
13
|
6
|
|
|
6
|
1
|
49
|
my ($self, $id) = @_; |
14
|
6
|
|
|
|
|
31
|
return $self->store->bag($id); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
1; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
__END__ |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=pod |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Catmandu::FileBag::Index - Flag a Bag as a FileStore Index |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Catmandu; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $store = Catmandu->store('Simple' , root => 't/data'); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# List all containers |
34
|
|
|
|
|
|
|
$store->bag->each(sub { |
35
|
|
|
|
|
|
|
my $container = shift; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
print "%s\n" , $container->{_id}; |
38
|
|
|
|
|
|
|
}); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Add a new folder |
41
|
|
|
|
|
|
|
$store->bag->add({ _id => '1234' }); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Get the v |
44
|
|
|
|
|
|
|
my $files = $store->bag->files('1234'); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Add a file to the files |
47
|
|
|
|
|
|
|
$files->upload(IO::File->new('<foobar.txt'), 'foobar.txt'); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Stream the contents of a file |
50
|
|
|
|
|
|
|
$files->stream(IO::File->new('>foobar.txt'), 'foobar.txt'); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Delete a file |
53
|
|
|
|
|
|
|
$files->delete('foobar.txt'); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Delete a folder |
56
|
|
|
|
|
|
|
$store->bag->delete('1234'); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 DESCRIPTION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Each L<Catmandu::FileBag> is a L<Catmandu::Bag> and inherits all its methods. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 METHODS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 files($id) |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Return the L<Catmandu::FileBag> for this L<Catmandu::FileStore> containing |
68
|
|
|
|
|
|
|
all the files |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SEE ALSO |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L<Catmandu::FileStore> , |
73
|
|
|
|
|
|
|
L<Catmandu::FileBag> |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |