line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Storage::Engine::IO::AtomicFile; |
2
|
|
|
|
|
|
|
# ABSTRACT: The actual atomic file storage mechanism. |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.50'; |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
17
|
use Moose; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
21
|
|
7
|
3
|
|
|
3
|
|
17442
|
use IO::AtomicFile; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
142
|
|
8
|
3
|
|
|
3
|
|
15
|
use Carp 'confess'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
134
|
|
9
|
3
|
|
|
3
|
|
15
|
use namespace::autoclean; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
24
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends 'MooseX::Storage::Engine::IO::File'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub store { |
14
|
4
|
|
|
4
|
1
|
9
|
my ($self, $data) = @_; |
15
|
4
|
|
33
|
|
|
161
|
my $fh = IO::AtomicFile->new($self->file, 'w') |
16
|
|
|
|
|
|
|
|| confess "Unable to open file (" . $self->file . ") for storing : $!"; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# TODO ugh! this is surely wrong and should be fixed. |
19
|
4
|
100
|
|
|
|
1053
|
$fh->binmode(':utf8') if utf8::is_utf8($data); |
20
|
4
|
|
|
|
|
54
|
print $fh $data; |
21
|
4
|
50
|
|
|
|
23
|
$fh->close() |
22
|
|
|
|
|
|
|
|| confess "Could not write atomic file (" . $self->file . ") because: $!"; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__END__ |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=pod |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=encoding UTF-8 |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
MooseX::Storage::Engine::IO::AtomicFile - The actual atomic file storage mechanism. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 VERSION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
version 0.50 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 DESCRIPTION |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
This provides the actual means to store data to a file atomically. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 METHODS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=over 4 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item B<file> |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item B<load> |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item B<store ($data)> |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=back |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 Introspection |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=over 4 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item B<meta> |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=back |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 BUGS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
All complex software has bugs lurking in it, and this module is no |
68
|
|
|
|
|
|
|
exception. If you find a bug please either email me, or add the bug |
69
|
|
|
|
|
|
|
to cpan-RT. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AUTHORS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=over 4 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item * |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Chris Prather <chris.prather@iinteractive.com> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item * |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Stevan Little <stevan.little@iinteractive.com> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
×××× ×§××'×× (Yuval Kogman) <nothingmuch@woobling.org> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=back |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This software is copyright (c) 2007 by Infinity Interactive, Inc.. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
94
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |