← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:09 2015

Filename/var/www/foswiki11/lib/Foswiki/Request/Upload.pm
StatementsExecuted 9 statements in 393µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11116µs32µsFoswiki::Request::Upload::::BEGIN@13Foswiki::Request::Upload::BEGIN@13
11111µs18µsFoswiki::Request::Upload::::BEGIN@14Foswiki::Request::Upload::BEGIN@14
11110µs26µsFoswiki::Request::Upload::::BEGIN@15Foswiki::Request::Upload::BEGIN@15
1114µs4µsFoswiki::Request::Upload::::BEGIN@17Foswiki::Request::Upload::BEGIN@17
0000s0sFoswiki::Request::Upload::::finishFoswiki::Request::Upload::finish
0000s0sFoswiki::Request::Upload::::handleFoswiki::Request::Upload::handle
0000s0sFoswiki::Request::Upload::::newFoswiki::Request::Upload::new
0000s0sFoswiki::Request::Upload::::tmpFileNameFoswiki::Request::Upload::tmpFileName
0000s0sFoswiki::Request::Upload::::uploadInfoFoswiki::Request::Upload::uploadInfo
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# See bottom of file for license and copyright information
2
3=begin TML
4
5---+!! package Foswiki::Request::Upload
6
7Class to encapsulate uploaded file info.
8
9=cut
10
11package Foswiki::Request::Upload;
12
13234µs249µs
# spent 32µs (16+16) within Foswiki::Request::Upload::BEGIN@13 which was called: # once (16µs+16µs) by Foswiki::Engine::CLI::BEGIN@24 at line 13
use strict;
# spent 32µs making 1 call to Foswiki::Request::Upload::BEGIN@13 # spent 16µs making 1 call to strict::import
14234µs225µs
# spent 18µs (11+7) within Foswiki::Request::Upload::BEGIN@14 which was called: # once (11µs+7µs) by Foswiki::Engine::CLI::BEGIN@24 at line 14
use warnings;
# spent 18µs making 1 call to Foswiki::Request::Upload::BEGIN@14 # spent 7µs making 1 call to warnings::import
15227µs243µs
# spent 26µs (10+16) within Foswiki::Request::Upload::BEGIN@15 which was called: # once (10µs+16µs) by Foswiki::Engine::CLI::BEGIN@24 at line 15
use Assert;
# spent 26µs making 1 call to Foswiki::Request::Upload::BEGIN@15 # spent 16µs making 1 call to Assert::import
16
172296µs14µs
# spent 4µs within Foswiki::Request::Upload::BEGIN@17 which was called: # once (4µs+0s) by Foswiki::Engine::CLI::BEGIN@24 at line 17
use IO::File ();
# spent 4µs making 1 call to Foswiki::Request::Upload::BEGIN@17
18
19=begin TML
20
21---++ ClassMethod new()
22
23Constructs a Foswiki::Request::Upload object
24
25=cut
26
27sub new {
28 my ( $proto, %args ) = @_;
29 my $class = ref($proto) || $proto;
30 my $this = {
31 headers => $args{headers},
32 tmpname => $args{tmpname},
33 };
34 return bless $this, $class;
35}
36
37=begin TML
38
39---++ ObjectMethod finish()
40
41Deletes temp file associated.
42
43=cut
44
45# Note to developers; please undef *all* fields in the object explicitly,
46# whether they are references or not. That way this method is "golden
47# documentation" of the live fields in the object.
48sub finish {
49 my $this = shift;
50 undef $this->{headers};
51
52 #SMELL: Note: untaint filename. Taken from CGI.pm
53 # (had to be updated for OSX in Dec2008)
54 $this->tmpFileName =~ m{^([a-zA-Z0-9_\+ \'\":/.\$\\~-]+)$};
55 my $file = $1;
56 if ( scalar( unlink($file) ) != 1 ) {
57 ASSERT( 0, "unable to unlink $file : $!" ) if DEBUG;
58 throw Error::Simple("unable to unlink $file : $!");
59 }
60 undef $this->{tmpname};
61}
62
63=begin TML
64
65---++ ObjectMethod uploadInfo() -> $headers
66
67Returns a hashref to information about uploaded
68file as sent by browser.
69
70=cut
71
72sub uploadInfo {
73 return $_[0]->{headers};
74}
75
76=begin TML
77
78---++ ObjectMethod handle() -> ( $fh )
79
80Returns an open filehandle to uploaded file.
81
82=cut
83
84sub handle {
85 my $fh = new IO::File( $_[0]->{tmpname}, '<' );
86 binmode $fh;
87 return $fh;
88}
89
90=begin TML
91
92---++ ObjectMethod tmpFileName() -> ( $tmpName )
93
94Returns the names of temporarly created file.
95
96=cut
97
98sub tmpFileName {
99 return $_[0]->{tmpname};
100}
101
10213µs1;
103__END__