X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FStorage%2FEngine%2FIO%2FFile.pm;h=a16222f4c7e49cad38c966ce8f431ba88a4ecb65;hb=efd4f7a5691295a10f74399e63731adb9a209057;hp=b5ba99d145d0f040b05de0dd2edc25b644503c04;hpb=7b428d1fd844e32dc3500a1fefc6cd794dc45fc8;p=gitmo%2FMooseX-Storage.git diff --git a/lib/MooseX/Storage/Engine/IO/File.pm b/lib/MooseX/Storage/Engine/IO/File.pm index b5ba99d..a16222f 100644 --- a/lib/MooseX/Storage/Engine/IO/File.pm +++ b/lib/MooseX/Storage/Engine/IO/File.pm @@ -1,10 +1,11 @@ - package MooseX::Storage::Engine::IO::File; use Moose; +use utf8 (); use IO::File; -our $VERSION = '0.01'; +our $VERSION = '0.35'; +our $AUTHORITY = 'cpan:STEVAN'; has 'file' => ( is => 'ro', @@ -14,13 +15,16 @@ has 'file' => ( sub load { my ($self) = @_; - my $fh = IO::File->new($self->file, 'r'); + my $fh = IO::File->new($self->file, 'r') + || confess "Unable to open file (" . $self->file . ") for loading : $!"; return do { local $/; <$fh>; }; } sub store { my ($self, $data) = @_; - my $fh = IO::File->new($self->file, 'w'); + my $fh = IO::File->new($self->file, 'w') + || confess "Unable to open file (" . $self->file . ") for storing : $!"; + $fh->binmode(':utf8') if utf8::is_utf8($data); print $fh $data; } @@ -72,7 +76,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