X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FRequest%2FUpload.pm;h=389f81043032c20c2a67b5c64a5ab744e3b23c8d;hb=47ae6960753acadac1da528c87c5d5009b675281;hp=ee1e5e234d5cd8cb28dee5eb15f0b698ed2b91af;hpb=4d89569d69f4b91b8faf4211128ab22e2b4965f4;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Request/Upload.pm b/lib/Catalyst/Request/Upload.pm index ee1e5e2..389f810 100644 --- a/lib/Catalyst/Request/Upload.pm +++ b/lib/Catalyst/Request/Upload.pm @@ -3,7 +3,8 @@ package Catalyst::Request::Upload; use strict; use base 'Class::Accessor::Fast'; -use IO::File; +use File::Copy (); +use IO::File (); __PACKAGE__->mk_accessors(qw/filename size tempname type/); @@ -15,6 +16,7 @@ Catalyst::Request::Upload - Catalyst Request Upload Class =head1 SYNOPSIS + $upload->copy $upload->fh $upload->filename; $upload->link; @@ -26,13 +28,24 @@ See also L. =head1 DESCRIPTION -This is the Catalyst Request Upload class, which provides a set of accessors to the -upload data. +This is the Catalyst Request Upload class, which provides a set of accessors +to the upload data. =head1 METHODS =over 4 +=item $upload->copy( $target [, $bufferlen ] ) + +Copies tempname using C. Returns true for success, false otherwise. + +=cut + +sub copy { + my ( $self, $target, $buffer ) = @_; + return File::Copy::copy( $self->tempname, $target, $buffer ); +} + =item $upload->fh Opens tempname and returns a C handle. @@ -42,7 +55,7 @@ Opens tempname and returns a C handle. sub fh { my $self = shift; - my $fh = IO::File->new( $self->tempname, O_RDONLY ) + my $fh = IO::File->new( $self->tempname, IO::File::O_RDONLY ) or die( "Can't open ", $self->tempname, ": ", $! ); return $fh; @@ -62,9 +75,7 @@ success, false otherwise. =cut sub link { - my $self = shift; - my $target = shift; - + my ( $self, $target ) = @_; return CORE::link( $self->tempname, $target ); }