line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Storage::Engine::IO::File; |
2
|
|
|
|
|
|
|
# ABSTRACT: The actual file storage mechanism. |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.53'; |
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
1125
|
use Moose; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
35
|
|
7
|
6
|
|
|
6
|
|
34599
|
use IO::File; |
|
6
|
|
|
|
|
1813
|
|
|
6
|
|
|
|
|
848
|
|
8
|
6
|
|
|
6
|
|
38
|
use Carp 'confess'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
239
|
|
9
|
6
|
|
|
6
|
|
32
|
use namespace::autoclean; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
54
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has 'file' => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
isa => 'Str', |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub load { |
18
|
9
|
|
|
9
|
1
|
4024
|
my ($self) = @_; |
19
|
9
|
|
33
|
|
|
261
|
my $fh = IO::File->new($self->file, 'r') |
20
|
|
|
|
|
|
|
|| confess "Unable to open file (" . $self->file . ") for loading : $!"; |
21
|
9
|
|
|
|
|
771
|
return do { local $/; <$fh>; }; |
|
9
|
|
|
|
|
40
|
|
|
9
|
|
|
|
|
393
|
|
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub store { |
25
|
5
|
|
|
5
|
1
|
16
|
my ($self, $data) = @_; |
26
|
5
|
|
33
|
|
|
149
|
my $fh = IO::File->new($self->file, 'w') |
27
|
|
|
|
|
|
|
|| confess "Unable to open file (" . $self->file . ") for storing : $!"; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# TODO ugh! this is surely wrong and should be fixed. |
30
|
5
|
100
|
|
|
|
1001
|
$fh->binmode(':utf8') if utf8::is_utf8($data); |
31
|
5
|
|
|
|
|
345
|
print $fh $data; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=pod |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=encoding UTF-8 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
MooseX::Storage::Engine::IO::File - The actual file storage mechanism. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 VERSION |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
version 0.53 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 DESCRIPTION |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This provides the actual means to store data to a file. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 METHODS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=over 4 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item B<file> |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item B<load> |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item B<store ($data)> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=back |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SUPPORT |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Storage> |
69
|
|
|
|
|
|
|
(or L<bug-MooseX-Storage@rt.cpan.org|mailto:bug-MooseX-Storage@rt.cpan.org>). |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
72
|
|
|
|
|
|
|
L<http://lists.perl.org/list/moose.html>. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
75
|
|
|
|
|
|
|
L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHORS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over 4 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Chris Prather <chris.prather@iinteractive.com> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Stevan Little <stevan.little@iinteractive.com> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item * |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
×××× ×§××'×× (Yuval Kogman) <nothingmuch@woobling.org> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=back |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This software is copyright (c) 2007 by Infinity Interactive, Inc. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
100
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |