line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Plugin::Upload::Basename; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
875
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
544
|
use Catalyst::Request::Upload; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use File::Spec::Unix; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
{ |
10
|
|
|
|
|
|
|
package Catalyst::Request::Upload; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub basename { |
13
|
|
|
|
|
|
|
my $self = shift; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
unless ( $self->{basename} ) { |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $basename = $self->filename; |
18
|
|
|
|
|
|
|
$basename =~ s|\\|/|g; |
19
|
|
|
|
|
|
|
$basename = ( File::Spec::Unix->splitpath($basename) )[2]; |
20
|
|
|
|
|
|
|
$basename =~ s|[^\w\.-]+|_|g; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$self->{basename} = $basename; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return $self->{basename}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
1; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__END__ |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Catalyst::Plugin::Upload::Basename - Basename for uploads |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use Catalyst qw[Upload::Basename]; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
if ( my $upload = $c->request->upload('field') ) { |
42
|
|
|
|
|
|
|
print $upload->basename; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 DESCRIPTION |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Extends C<Catalyst::Request::Upload> with a basename method. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 METHODS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=over 4 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item basename |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Returns basename for C<filename>. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=back |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SEE ALSO |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
L<Catalyst::Request>, L<Catalyst::Request::Upload>. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 AUTHOR |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Christian Hansen, C<ch@ngmedia.com> |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 LICENSE |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This library is free software . You can redistribute it and/or modify it under |
71
|
|
|
|
|
|
|
the same terms as perl itself. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |