| 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.50'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
1369
|
use Moose; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
40
|
|
|
7
|
6
|
|
|
6
|
|
35988
|
use IO::File; |
|
|
6
|
|
|
|
|
1988
|
|
|
|
6
|
|
|
|
|
1227
|
|
|
8
|
6
|
|
|
6
|
|
32
|
use Carp 'confess'; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
243
|
|
|
9
|
6
|
|
|
6
|
|
33
|
use namespace::autoclean; |
|
|
6
|
|
|
|
|
12
|
|
|
|
6
|
|
|
|
|
52
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has 'file' => ( |
|
12
|
|
|
|
|
|
|
is => 'ro', |
|
13
|
|
|
|
|
|
|
isa => 'Str', |
|
14
|
|
|
|
|
|
|
required => 1, |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub load { |
|
18
|
9
|
|
|
9
|
1
|
4540
|
my ($self) = @_; |
|
19
|
9
|
|
33
|
|
|
349
|
my $fh = IO::File->new($self->file, 'r') |
|
20
|
|
|
|
|
|
|
|| confess "Unable to open file (" . $self->file . ") for loading : $!"; |
|
21
|
9
|
|
|
|
|
1023
|
return do { local $/; <$fh>; }; |
|
|
9
|
|
|
|
|
43
|
|
|
|
9
|
|
|
|
|
361
|
|
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub store { |
|
25
|
5
|
|
|
5
|
1
|
11
|
my ($self, $data) = @_; |
|
26
|
5
|
|
33
|
|
|
205
|
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
|
|
|
|
1257
|
$fh->binmode(':utf8') if utf8::is_utf8($data); |
|
31
|
5
|
|
|
|
|
574530
|
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.50 |
|
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
|
|
|
|
|
|
|
=head2 Introspection |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=over 4 |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item B<meta> |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=back |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 BUGS |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
All complex software has bugs lurking in it, and this module is no |
|
77
|
|
|
|
|
|
|
exception. If you find a bug please either email me, or add the bug |
|
78
|
|
|
|
|
|
|
to cpan-RT. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 AUTHORS |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=over 4 |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Chris Prather <chris.prather@iinteractive.com> |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Stevan Little <stevan.little@iinteractive.com> |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
×××× ×§××'×× (Yuval Kogman) <nothingmuch@woobling.org> |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This software is copyright (c) 2007 by Infinity Interactive, Inc.. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
103
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |