← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:27:04 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Request/Upload.pm
StatementsExecuted 9 statements in 585µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11130µs38µsFoswiki::Request::Upload::::BEGIN@13Foswiki::Request::Upload::BEGIN@13
11117µs38µsFoswiki::Request::Upload::::BEGIN@14Foswiki::Request::Upload::BEGIN@14
11116µs59µsFoswiki::Request::Upload::::BEGIN@15Foswiki::Request::Upload::BEGIN@15
1119µs9µ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
13247µs246µs
# spent 38µs (30+8) within Foswiki::Request::Upload::BEGIN@13 which was called: # once (30µs+8µs) by Foswiki::Engine::CGI::BEGIN@23 at line 13
use strict;
# spent 38µs making 1 call to Foswiki::Request::Upload::BEGIN@13 # spent 8µs making 1 call to strict::import
14245µs259µs
# spent 38µs (17+21) within Foswiki::Request::Upload::BEGIN@14 which was called: # once (17µs+21µs) by Foswiki::Engine::CGI::BEGIN@23 at line 14
use warnings;
# spent 38µs making 1 call to Foswiki::Request::Upload::BEGIN@14 # spent 21µs making 1 call to warnings::import
15244µs2102µs
# spent 59µs (16+43) within Foswiki::Request::Upload::BEGIN@15 which was called: # once (16µs+43µs) by Foswiki::Engine::CGI::BEGIN@23 at line 15
use Assert;
# spent 59µs making 1 call to Foswiki::Request::Upload::BEGIN@15 # spent 43µs making 1 call to Assert::import
16
172446µs19µs
# spent 9µs within Foswiki::Request::Upload::BEGIN@17 which was called: # once (9µs+0s) by Foswiki::Engine::CGI::BEGIN@23 at line 17
use IO::File ();
# spent 9µ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
10214µs1;
103__END__