line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Xtract::LZMA; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Abstracts LZMA support across multiple implementations |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
105
|
use 5.008005; |
|
5
|
|
|
|
|
18
|
|
|
5
|
|
|
|
|
243
|
|
6
|
5
|
|
|
5
|
|
33
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
718
|
|
7
|
5
|
|
|
5
|
|
29
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
624
|
|
8
|
5
|
|
|
5
|
|
28
|
use Carp (); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
83
|
|
9
|
5
|
|
|
5
|
|
2224
|
use File::Which (); |
|
5
|
|
|
|
|
2803
|
|
|
5
|
|
|
|
|
258
|
|
10
|
5
|
|
|
5
|
|
896
|
use IPC::Run3 (); |
|
5
|
|
|
|
|
32495
|
|
|
5
|
|
|
|
|
2826
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.16'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $LZMA = ''; |
15
|
|
|
|
|
|
|
my @WHICH = (); |
16
|
|
|
|
|
|
|
if ( $^O eq 'MSWin32' ) { |
17
|
|
|
|
|
|
|
require Alien::Win32::LZMA; |
18
|
|
|
|
|
|
|
$LZMA = 'win32'; |
19
|
|
|
|
|
|
|
} elsif ( @WHICH = File::Which::which('lzma') ) { |
20
|
|
|
|
|
|
|
$LZMA = 'unix'; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
##################################################################### |
28
|
|
|
|
|
|
|
# API Methods |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub available { |
31
|
4
|
|
|
4
|
0
|
6575
|
return !! $LZMA; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub compress { |
35
|
3
|
|
|
3
|
0
|
8
|
my $class = shift; |
36
|
3
|
50
|
|
|
|
20
|
if ( $LZMA eq 'win32' ) { |
|
|
50
|
|
|
|
|
|
37
|
0
|
|
|
|
|
0
|
return $class->_win32(@_); |
38
|
|
|
|
|
|
|
} elsif ( $LZMA eq 'unix' ) { |
39
|
3
|
|
|
|
|
18
|
return $class->_unix(@_); |
40
|
|
|
|
|
|
|
} |
41
|
0
|
|
|
|
|
0
|
Carp::croak('LZMA support is not available'); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _win32 { |
45
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
46
|
0
|
0
|
|
|
|
0
|
unless ( Alien::Win32::LZMA::lzma_compress(@_) ) { |
47
|
0
|
|
|
|
|
0
|
die "Failed to compress '$_[0]'"; |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
0
|
return 1; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _unix { |
53
|
3
|
|
|
3
|
|
88
|
my $class = shift; |
54
|
3
|
|
|
|
|
6
|
my $from = shift; |
55
|
3
|
|
|
|
|
7
|
my $to = shift; |
56
|
3
|
|
|
|
|
8
|
my $stdout = ''; |
57
|
3
|
|
|
|
|
7
|
my $stderr = ''; |
58
|
3
|
|
|
|
|
31
|
my $result = IPC::Run3::run3( |
59
|
|
|
|
|
|
|
[ |
60
|
|
|
|
|
|
|
$WHICH[0], |
61
|
|
|
|
|
|
|
'--compress', |
62
|
|
|
|
|
|
|
'--keep', |
63
|
|
|
|
|
|
|
'--suffix', '.lz', |
64
|
|
|
|
|
|
|
$from, |
65
|
|
|
|
|
|
|
], \undef, \$stdout, \$stderr, |
66
|
|
|
|
|
|
|
); |
67
|
3
|
50
|
33
|
|
|
27050842
|
unless ( $result and -f $to ) { |
68
|
0
|
|
|
|
|
0
|
die 'Failed to lzma SQLite file'; |
69
|
|
|
|
|
|
|
} |
70
|
3
|
|
|
|
|
72
|
return 1; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |