| 1 | package Dicom::File::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 Error::Pure qw(err); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 3 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | # Constants. | ||||||||||
| 11 | 3 | Readonly::Array our @EXPORT => qw(dicom_detect_file); | |||||||||
| 12 | 3 | Readonly::Scalar our $DCM_MAGIC => qw{DICM}; | |||||||||
| 13 | |||||||||||
| 14 | 3 | our $VERSION = 0.05; | |||||||||
| 15 | |||||||||||
| 16 | # Detect DICOM file. | ||||||||||
| 17 | 3 | ▶ | sub dicom_detect_file { | ||||||||
|
Subroutine
dicom_detect_file: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 18 | 3 | my $file = shift; | |||||||||
| 19 | |||||||||||
| 20 | 3 | my $dcm_flag = 0; | |||||||||
| 21 | 3 | ▶ | open my $fh, '<', $file or err "Cannot open file '$file'."; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 2 | my $seek = seek $fh, 128, 0; | |||||||||
| 23 | 2 | my $magic; | |||||||||
| 24 | 2 | my $read = read $fh, $magic, 4; | |||||||||
| 25 | 2 | ▶ | close $fh or err "Cannot close file '$file'."; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | |||||||||||
| 27 | 2 | ▶ | if ($magic eq $DCM_MAGIC) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 1 | return 1; | |||||||||
| 29 | } else { | ||||||||||
| 30 | 1 | return 0; | |||||||||
| 31 | } | ||||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 3 | 1; | |||||||||
| 35 | |||||||||||
| 36 | __END__ | ||||||||||