line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CAD::AutoCAD::Detect; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
78148
|
use base qw(Exporter); |
|
3
|
|
|
|
|
19
|
|
|
3
|
|
|
|
|
477
|
|
4
|
3
|
|
|
3
|
|
22
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
72
|
|
5
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
101
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1628
|
use CAD::AutoCAD::Version; |
|
3
|
|
|
|
|
98502
|
|
|
3
|
|
|
|
|
126
|
|
8
|
3
|
|
|
3
|
|
26
|
use Error::Pure qw(err); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
134
|
|
9
|
3
|
|
|
3
|
|
18
|
use List::MoreUtils qw(any); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
21
|
|
10
|
3
|
|
|
3
|
|
1977
|
use Readonly; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
851
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Constants. |
13
|
|
|
|
|
|
|
Readonly::Array our @EXPORT => qw(detect_dwg_file); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = 0.03; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Detect DWG file. |
18
|
|
|
|
|
|
|
sub detect_dwg_file { |
19
|
5
|
|
|
5
|
1
|
2669
|
my $file = shift; |
20
|
|
|
|
|
|
|
|
21
|
5
|
|
|
|
|
8
|
my $dwg_flag = 0; |
22
|
5
|
100
|
|
|
|
231
|
open my $fh, '<', $file or err "Cannot open file '$file'."; |
23
|
4
|
|
|
|
|
13
|
my $magic; |
24
|
4
|
|
|
|
|
68
|
my $read = read $fh, $magic, 6; |
25
|
4
|
50
|
|
|
|
57
|
close $fh or err "Cannot close file '$file'."; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Remove NULL characters from end of string. |
28
|
4
|
|
|
|
|
22
|
$magic =~ s/\x00$//; |
29
|
|
|
|
|
|
|
|
30
|
4
|
100
|
66
|
19
|
|
40
|
if ($read == 6 && (any { $_ eq $magic } |
|
19
|
|
|
|
|
394
|
|
31
|
|
|
|
|
|
|
CAD::AutoCAD::Version->list_of_acad_identifiers)) { |
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
23
|
return $magic; |
34
|
|
|
|
|
|
|
} else { |
35
|
1
|
|
|
|
|
7
|
return; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |