X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FStorage%2FEngine%2FIO%2FAtomicFile.pm;h=c84c3667a7f590d7d6e3e4bd868a86b3eab4aa2c;hb=d92b2381821e049808c6b9ddc9c09553e2a78290;hp=6c58228057c79a483b1de3df8654ae6fc64e1589;hpb=69b45b7d79fa7628879179765a6deba184f92fdf;p=gitmo%2FMooseX-Storage.git diff --git a/lib/MooseX/Storage/Engine/IO/AtomicFile.pm b/lib/MooseX/Storage/Engine/IO/AtomicFile.pm index 6c58228..c84c366 100644 --- a/lib/MooseX/Storage/Engine/IO/AtomicFile.pm +++ b/lib/MooseX/Storage/Engine/IO/AtomicFile.pm @@ -1,21 +1,18 @@ - package MooseX::Storage::Engine::IO::AtomicFile; use Moose; use IO::AtomicFile; -our $VERSION = '0.02'; -our $AUTHORITY = 'cpan:STEVAN'; - extends 'MooseX::Storage::Engine::IO::File'; sub store { - my ($self, $data) = @_; - my $fh = IO::AtomicFile->new($self->file, 'w') - || confess "Unable to open file (" . $self->file . ") for storing : $!"; - print $fh $data; - $fh->close() - || confess "Could not write atomic file (" . $self->file . ") because: $!"; + my ($self, $data) = @_; + my $fh = IO::AtomicFile->new($self->file, 'w') + || confess "Unable to open file (" . $self->file . ") for storing : $!"; + $fh->binmode(':utf8') if utf8::is_utf8($data); + print $fh $data; + $fh->close() + || confess "Could not write atomic file (" . $self->file . ") because: $!"; } 1; @@ -54,7 +51,7 @@ This provides the actual means to store data to a file atomically. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. @@ -66,7 +63,7 @@ Stevan Little Estevan.little@iinteractive.comE =head1 COPYRIGHT AND LICENSE -Copyright 2007 by Infinity Interactive, Inc. +Copyright 2007-2008 by Infinity Interactive, Inc. L