line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Gopher::Server::TypeMapper; |
3
|
2
|
|
|
2
|
|
20876
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
68
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
68
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1678
|
use overload q("") => \&as_string; |
|
2
|
|
|
|
|
1279
|
|
|
2
|
|
|
|
|
23
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Constants |
9
|
|
|
|
|
|
|
sub GOPHER_TYPE () { 0 } |
10
|
|
|
|
|
|
|
sub MIME_TYPE () { 1 } |
11
|
10
|
|
|
10
|
0
|
75
|
sub TYPES () {{ |
12
|
|
|
|
|
|
|
txt => [ '0', 'text/plain' ], |
13
|
|
|
|
|
|
|
directory => [ '1', '' ], |
14
|
|
|
|
|
|
|
default => [ '9', 'application/data' ], |
15
|
|
|
|
|
|
|
}} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub get_type |
19
|
|
|
|
|
|
|
{ |
20
|
5
|
|
|
5
|
0
|
102948
|
my ($class, $in) = @_; |
21
|
|
|
|
|
|
|
|
22
|
5
|
100
|
|
|
|
18
|
my $ext = $in->{extention} ? $in->{extention} : ''; |
23
|
5
|
100
|
|
|
|
19
|
unless($ext) { |
24
|
3
|
50
|
|
|
|
9
|
my $filename = $in->{filename} |
25
|
|
|
|
|
|
|
or die "Need a filename or extention"; |
26
|
|
|
|
|
|
|
|
27
|
3
|
100
|
|
|
|
56
|
if( -d $filename ) { |
28
|
1
|
|
|
|
|
2
|
$ext = 'directory'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
2
|
|
|
|
|
29
|
($ext) = $filename =~ / \. (\w+) \z/x; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
2
|
|
462
|
no warnings; # Shut off warnings for case where $ext isn't defined |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
330
|
|
36
|
5
|
100
|
|
|
|
15
|
my $self = exists TYPES->{$ext} ? TYPES->{$ext} : TYPES->{default}; |
37
|
5
|
|
|
|
|
38
|
bless $self => $class; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
6
|
|
|
6
|
0
|
4334
|
sub gopher_type { $_[0]->[GOPHER_TYPE] } |
42
|
5
|
|
|
5
|
0
|
22
|
sub mime_type { $_[0]->[MIME_TYPE] } |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
1
|
0
|
4
|
sub as_string { $_[0]->gopher_type } |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
__END__ |