File Coverage

blib/lib/Archive/Unzip/Burst.pm
Criterion Covered Total %
statement 23 25 92.0
branch 6 10 60.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 35 41 85.3


line stmt bran cond sub pod time code
1             package Archive::Unzip::Burst;
2              
3             # The license of this Perl code is the same as that of perl itself.
4             # The documentation which should be embedded at the end of this file
5             # should contain more details.
6             #
7             # The license of the InfoZip library which is used by this module is
8             # reproduced in full in the following paragraphs:
9             #
10             # This is version 2005-Feb-10 of the Info-ZIP copyright and license.
11             # The definitive version of this document should be available at
12             # ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely.
13             #
14             #
15             # Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
16             #
17             # For the purposes of this copyright and license, "Info-ZIP" is defined as
18             # the following set of individuals:
19             #
20             # Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois,
21             # Jean-loup Gailly, Hunter Goatley, Ed Gordon, Ian Gorman, Chris Herborth,
22             # Dirk Haase, Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz,
23             # David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko,
24             # Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs,
25             # Kai Uwe Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda,
26             # Christian Spieler, Cosmin Truta, Antoine Verheijen, Paul von Behren,
27             # Rich Wales, Mike White
28             #
29             # This software is provided "as is," without warranty of any kind, express
30             # or implied. In no event shall Info-ZIP or its contributors be held liable
31             # for any direct, indirect, incidental, special or consequential damages
32             # arising out of the use of or inability to use this software.
33             #
34             # Permission is granted to anyone to use this software for any purpose,
35             # including commercial applications, and to alter it and redistribute it
36             # freely, subject to the following restrictions:
37             #
38             # 1. Redistributions of source code must retain the above copyright notice,
39             # definition, disclaimer, and this list of conditions.
40             #
41             # 2. Redistributions in binary form (compiled executables) must reproduce
42             # the above copyright notice, definition, disclaimer, and this list of
43             # conditions in documentation and/or other materials provided with the
44             # distribution. The sole exception to this condition is redistribution
45             # of a standard UnZipSFX binary (including SFXWiz) as part of a
46             # self-extracting archive; that is permitted without inclusion of this
47             # license, as long as the normal SFX banner has not been removed from
48             # the binary or disabled.
49             #
50             # 3. Altered versions--including, but not limited to, ports to new operating
51             # systems, existing ports with new graphical interfaces, and dynamic,
52             # shared, or static library versions--must be plainly marked as such
53             # and must not be misrepresented as being the original source. Such
54             # altered versions also must not be misrepresented as being Info-ZIP
55             # releases--including, but not limited to, labeling of the altered
56             # versions with the names "Info-ZIP" (or any variation thereof, including,
57             # but not limited to, different capitalizations), "Pocket UnZip," "WiZ"
58             # or "MacZip" without the explicit permission of Info-ZIP. Such altered
59             # versions are further prohibited from misrepresentative use of the
60             # Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s).
61             #
62             # 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip,"
63             # "UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its
64             # own source and binary releases.
65              
66              
67 2     2   108169 use 5.006;
  2         14  
68 2     2   8 use strict;
  2         5  
  2         47  
69 2     2   8 use warnings;
  2         9  
  2         70  
70              
71             BEGIN {
72 2 50   2   112 if (eval "require prefork;") {
73 0         0 eval "prefork->import(qw/Cwd File::Spec/)";
74             }
75             }
76              
77             require Exporter;
78              
79             our @ISA = qw(Exporter);
80              
81             our %EXPORT_TAGS = ( 'all' => [ qw(
82             unzip
83             ) ] );
84              
85             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
86              
87             our @EXPORT = qw();
88              
89             our $VERSION = '0.09';
90              
91             require XSLoader;
92             XSLoader::load('Archive::Unzip::Burst', $VERSION);
93              
94             sub unzip {
95 2     2 1 34150 my $filename = shift;
96 2         10 my $dir = shift;
97 2         26 require Cwd;
98 2         11 require File::Spec;
99 2 50       31 if (not -f $filename) {
100 0         0 die "ZIP file not found: $filename";
101             }
102 2         20 my $file_is_abs = File::Spec->file_name_is_absolute($filename);
103 2 100       11 if (not $file_is_abs) {
104 1         31 $filename = File::Spec->rel2abs($filename);
105             }
106 2         4658 my $olddir = Cwd::cwd();
107 2         122 mkdir($dir);
108 2 50       53 chdir($dir) or die $!;
109 2         1535 my $ret = _unzip($filename);
110 2 50       48 chdir($olddir) or die $!;
111 2         98 return $ret;
112             }
113              
114             1;
115             __END__