line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CAD::AutoCAD::Detect; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
73410
|
use base qw(Exporter); |
|
3
|
|
|
|
|
28
|
|
|
3
|
|
|
|
|
441
|
|
4
|
3
|
|
|
3
|
|
21
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
69
|
|
5
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
98
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1616
|
use CAD::AutoCAD::Version; |
|
3
|
|
|
|
|
88665
|
|
|
3
|
|
|
|
|
118
|
|
8
|
3
|
|
|
3
|
|
23
|
use Error::Pure qw(err); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
125
|
|
9
|
3
|
|
|
3
|
|
16
|
use List::MoreUtils qw(any); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
13
|
|
10
|
3
|
|
|
3
|
|
1923
|
use Readonly; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
753
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Constants. |
13
|
|
|
|
|
|
|
Readonly::Array our @EXPORT => qw(detect_dwg_file); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = 0.02; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Detect DWG file. |
18
|
|
|
|
|
|
|
sub detect_dwg_file { |
19
|
5
|
|
|
5
|
1
|
2625
|
my $file = shift; |
20
|
|
|
|
|
|
|
|
21
|
5
|
|
|
|
|
10
|
my $dwg_flag = 0; |
22
|
5
|
100
|
|
|
|
215
|
open my $fh, '<', $file or err "Cannot open file '$file'."; |
23
|
4
|
|
|
|
|
13
|
my $magic; |
24
|
4
|
|
|
|
|
62
|
my $read = read $fh, $magic, 6; |
25
|
4
|
50
|
|
|
|
53
|
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
|
53
|
|
41
|
if ($read == 6 && (any { $_ eq $magic } |
|
53
|
|
|
|
|
411
|
|
31
|
|
|
|
|
|
|
CAD::AutoCAD::Version->list_of_acad_identifiers)) { |
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
23
|
return $magic; |
34
|
|
|
|
|
|
|
} else { |
35
|
1
|
|
|
|
|
6
|
return; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |