File Coverage

blib/lib/Parse/Win32Registry.pm
Criterion Covered Total %
statement 40 46 86.9
branch 8 12 66.6
condition 1 3 33.3
subroutine 12 14 85.7
pod 1 5 20.0
total 62 80 77.5


line stmt bran cond sub pod time code
1             package Parse::Win32Registry;
2              
3 13     13   501408 use 5.008_001;
  13         56  
  13         518  
4 13     13   80 use strict;
  13         28  
  13         593  
5 13     13   61 use warnings;
  13         39  
  13         635  
6              
7             our $VERSION = '1.0';
8              
9 13     13   66 use base qw(Exporter);
  13         20  
  13         2048  
10              
11 13     13   71 use Carp;
  13         24  
  13         1048  
12 13     13   14915 use Encode;
  13         182666  
  13         2209  
13 13     13   9566 use Parse::Win32Registry::Base qw(:all);
  13         52  
  13         4740  
14 13     13   10723 use Parse::Win32Registry::Win95::File;
  13         38  
  13         427  
15 13     13   9774 use Parse::Win32Registry::WinNT::File;
  13         48  
  13         6819  
16              
17             our @EXPORT_OK = (
18             # include old function names for backwards compatibility
19             'convert_filetime_to_epoch_time',
20             'formatted_octets',
21             @Parse::Win32Registry::Base::EXPORT_OK
22             );
23              
24             our %EXPORT_TAGS = (
25             REG_ => [grep { /^REG_[A-Z_]*$/ } @EXPORT_OK],
26             all => [@EXPORT_OK],
27             functions => [grep { /^[a-z0-9_]*$/ } @EXPORT_OK],
28             constants => [grep { /^[A-Z_]*$/ } @EXPORT_OK],
29             );
30              
31             *convert_filetime_to_epoch_time = \&Parse::Win32Registry::unpack_windows_time;
32             *formatted_octets = \&Parse::Win32Registry::format_octets;
33              
34             sub enable_warnings {
35 1     1 0 6 $Parse::Win32Registry::Base::WARNINGS = 1;
36             }
37              
38             sub disable_warnings {
39 1     1 0 9 $Parse::Win32Registry::Base::WARNINGS = 0;
40             }
41              
42             sub set_codepage {
43 0     0 0 0 my $codepage = shift;
44 0 0       0 if (defined $codepage) {
45 0         0 $Parse::Win32Registry::Base::CODEPAGE = $codepage;
46             }
47             }
48              
49             sub get_codepage {
50 0     0 0 0 $Parse::Win32Registry::Base::CODEPAGE;
51             }
52              
53             sub new {
54 54     54 1 39737 my $class = shift;
55 54 100       395 my $filename = shift or croak "No filename specified";
56              
57 53 50       2379 open my $regfile, "<", $filename or croak "Unable to open '$filename': $!";
58 53         478 sysread($regfile, my $sig, 4);
59 53 50 33     405 if (!defined($sig) || length($sig) != 4) {
60 0         0 warnf("Could not read registry file header");
61 0         0 return;
62             }
63 53         791 close $regfile;
64              
65 53 100       913 if ($sig eq "CREG") {
    100          
66             # attempt to parse this as a Windows 95 Registry File
67 16         167 return Parse::Win32Registry::Win95::File->new($filename);
68             }
69             elsif ($sig eq "regf") {
70             # attempt to parse this as a Windows NT Registry File
71 35         291 return Parse::Win32Registry::WinNT::File->new($filename);
72             }
73             else {
74 2         11 warnf("Invalid registry file header");
75 2         30 return;
76             }
77             }
78              
79             1;
80              
81             __END__