Skip to content

Commit

Permalink
Rewrite iindirect "new" to "->new"
Browse files Browse the repository at this point in the history
  • Loading branch information
pmqs committed Aug 29, 2024
1 parent d3fc968 commit 68c9fd0
Show file tree
Hide file tree
Showing 8 changed files with 311 additions and 281 deletions.
25 changes: 25 additions & 0 deletions examples/gz2zip.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use strict;
use warnings;

use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
use Archive::Zip::SimpleZip qw($SimpleZipError);

die "Usage: gz2zip.pl zipfilename gzfile1 gzfile2...\n"
unless @ARGV >= 2 ;

my $zipFile = shift ;
my $zip = Archive::Zip::SimpleZip->new($zipFile)
or die "Cannot create zip file '$zipFile': $SimpleZipError";

for my $gzFile (@ARGV)
{
my $cleanName = $gzFile ;
$cleanName =~ s/\.gz$//;

print "Adding $cleanName\n" ;
my $zipMember = $zip->openMember(Name => $cleanName)
or die "Cannot openMember file '$cleanName': $SimpleZipError\n" ;

gunzip $gzFile => $zipMember
or die "Cannot gunzip file '$gzFile': $GunzipError $SimpleZipError\n" ;
}
48 changes: 24 additions & 24 deletions lib/Archive/Zip/SimpleUnzip.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ our %PARAMS = (

sub _ckParams
{
my $got = IO::Compress::Base::Parameters::new();
my $got = IO::Compress::Base::Parameters->new();

$got->parse(\%PARAMS, @_)
or _myDie("Parameter Error: " . $got->getError()) ;
Expand Down Expand Up @@ -94,7 +94,7 @@ sub new
return _illegalFilename
}

$fh = new IO::File "<$inValue"
$fh = IO::File->new("<$inValue")
or return _setError(undef, undef, "cannot open file '$inValue': $!");
}
elsif( $inType eq 'buffer' || $inType eq 'handle')
Expand Down Expand Up @@ -806,7 +806,7 @@ sub STORABLE_thaw
if ($self->isFile())
{
my $handle = $self->open();
my $fh = new IO::File ">$filename"
my $fh = IO::File->new(">$filename")
or return _setError("Cannot open file '$filename': $!");
#$fh->binmode(); # not available in 5.8.0

Expand Down Expand Up @@ -972,7 +972,7 @@ Archive::Zip::SimpleUnzip - Read Zip Archives
use Archive::Zip::SimpleUnzip qw($SimpleUnzipError) ;
my $z = new Archive::Zip::SimpleUnzip "my.zip"
my $z = Archive::Zip::SimpleUnzip->NEW('my.zip')
or die "Cannot open zip file: $SimpleUnzipError\n" ;
# How many members in the archive?
Expand All @@ -982,21 +982,21 @@ Archive::Zip::SimpleUnzip - Read Zip Archives
my @names = $z->names();
# Test member existence
if ($z->exists("abc.txt"))
if ($z->exists('abc.txt'))
{
...
}
# Extract member to filesystem
$z->extract("member") ;
$z->extract("member", "outfile") ;
$z->extract('member') ;
$z->extract('member', 'outfile') ;
# Read the zip comment
my $comment = $zip->comment();
# Select a member by name
my $member = $z->member("abc.txt");
my $member = $z->member('abc.txt');
my $name = $member->name();
my $content = $member->content();
my $comment = $member->comment();
Expand Down Expand Up @@ -1050,9 +1050,9 @@ Note that the code assume that the zip archive is being read from a seekable fil
=head2 Constructor
$z = new Archive::Zip::SimpleUnzip "myzipfile.zip" [, OPTIONS] ;
$z = new Archive::Zip::SimpleUnzip \$buffer [, OPTIONS] ;
$z = new Archive::Zip::SimpleUnzip $filehandle [, OPTIONS] ;
$z = Archive::Zip::SimpleUnzip->new('myzipfile.zip' [, OPTIONS]) ;
$z = Archive::Zip::SimpleUnzip->new(\$buffer [, OPTIONS]) ;
$z = Archive::Zip::SimpleUnzip->new($filehandle [, OPTIONS]) ;
The constructor takes one mandatory parameter along with zero or more
optional parameters.
Expand Down Expand Up @@ -1117,7 +1117,7 @@ If the optional parameter $outfile is specified, the payload is written to that
Returns the comment, if any, associated with the zip archive.
=item $z->exists("name")
=item $z->exists('name')
Tests for the existence of member "name" in the zip archive.
Expand All @@ -1139,10 +1139,10 @@ Standard usage is
use Archive::Zip::SimpleUnzip qw($SimpleUnzipError) ;
my $match = "hello";
my $zipfile = "my.zip";
my $match = 'hello';
my $zipfile = 'my.zip';
my $z = new Archive::Zip::SimpleUnzip $zipfile
my $z = Archive::Zip::SimpleUnzip->new($zipfile)
or die "Cannot open zip file: $SimpleUnzipError\n" ;
while (my $member = $z->next())
Expand Down Expand Up @@ -1215,10 +1215,10 @@ read the contents of the member
use Archive::Zip::SimpleUnzip qw($SimpleUnzipError) ;
my $z = new Archive::Zip::SimpleUnzip "my1.zip"
my $z = Archive::Zip::SimpleUnzip->new('my1.zip')
or die "Cannot open zip file: $SimpleUnzipError\n" ;
my $name = "abc.txt";
my $name = 'abc.txt';
if ($z->exists($name))
{
print $z->content($name);
Expand All @@ -1232,8 +1232,8 @@ read the contents of the member
use Archive::Zip::SimpleUnzip qw($SimpleUnzipError) ;
my $zipfile = "my.zip";
my $z = new Archive::Zip::SimpleUnzip $zipfile
my $zipfile = 'my.zip';
my $z = Archive::Zip::SimpleUnzip->new($zipfile)
or die "Cannot open zip file: $SimpleUnzipError\n" ;
my $members = $z->names();
Expand All @@ -1253,10 +1253,10 @@ constructor to automaticaly skip members that just contain directories.
use Archive::Zip::SimpleUnzip qw($SimpleUnzipError) ;
my $match = "hello";
my $zipfile = "my.zip";
my $match = 'hello';
my $zipfile = 'my.zip';
my $z = new Archive::Zip::SimpleUnzip $zipfile, FilesOnly => 1
my $z = Archive::Zip::SimpleUnzip->new($zipfile, FilesOnly => 1)
or die "Cannot open zip file: $SimpleUnzipError\n" ;
while (my $member = $z->next())
Expand All @@ -1282,10 +1282,10 @@ to get a filehandle for each member of a zip archive which it passes to C<Archi
my $input = shift ;
my $output = shift ;
my $unzip = new Archive::Zip::SimpleUnzip $input
my $unzip = Archive::Zip::SimpleUnzip->new($input)
or die "Cannot open '$input': $SimpleUnzipError";
my $zip = new Archive::Zip::SimpleZip $output, Level => Z_BEST_COMPRESSION
my $zip = Archive::Zip::SimpleZip->new($output, Level => Z_BEST_COMPRESSION)
or die "Cannot create zip file '$output': $SimpleZipError";
while (my $member = $unzip->next())
Expand Down
Loading

0 comments on commit 68c9fd0

Please sign in to comment.