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