| 1 | package CAD::AutoCAD::Detect; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use CAD::AutoCAD::Version; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Error::Pure qw(err); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use List::MoreUtils qw(any); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | # Constants. | ||||||||||||||||||||||||||||
| 13 | 3 | Readonly::Array our @EXPORT => qw(detect_dwg_file); | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 3 | our $VERSION = 0.03; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # Detect DWG file. | ||||||||||||||||||||||||||||
| 18 | sub detect_dwg_file { | ||||||||||||||||||||||||||||
| 19 | 5 | ▶ | my $file = shift; | ||||||||||||||||||||||||||
|
Subroutine
detect_dwg_file: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 5 | my $dwg_flag = 0; | |||||||||||||||||||||||||||
| 22 | 5 | ▶ | open my $fh, '<', $file or err "Cannot open file '$file'."; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 4 | my $magic; | |||||||||||||||||||||||||||
| 24 | 4 | my $read = read $fh, $magic, 6; | |||||||||||||||||||||||||||
| 25 | 4 | ▶ | close $fh or err "Cannot close file '$file'."; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # Remove NULL characters from end of string. | ||||||||||||||||||||||||||||
| 28 | 4 | $magic =~ s/\x00$//; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 4 | ▶ | if ($read == 6 && (any { $_ eq $magic } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition66%2/3
$read == 6 and &any(sub {
$_ eq $magic;
}
, "CAD::AutoCAD::Version"->list_of_acad_identifiers)
MC/DC50%1/2
$read == 6 and &any(sub {
$_ eq $magic;
}
, "CAD::AutoCAD::Version"->list_of_acad_identifiers)
$read == 6
&any(sub {
$_ eq $magic;
}
, "CAD::AutoCAD::Version"->list_of_acad_identifiers)
Truth table66%2/3
A and B
A= $read == 6B= &any(sub {
$_ eq $magic;
}
, "CAD::AutoCAD::Version"->list_of_acad_identifiers)
| |||||||||||||||||||||||||||||
| 31 | CAD::AutoCAD::Version->list_of_acad_identifiers)) { | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 3 | return $magic; | |||||||||||||||||||||||||||
| 34 | } else { | ||||||||||||||||||||||||||||
| 35 | 1 | return; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 3 | 1; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | __END__ | ||||||||||||||||||||||||||||