tech_trix
10-24-2007, 04:33 AM
Hi, I am trying to zip some files using Archive::ZIP package of perl.It is zipping the file properly.Problem comes while unzipping.When i try to unzip the zip file manually using winzip or without using any perl code then its unzips the content but it creates a folder and unzips the file in that folder.I dont want that folder to be generated while unzipping.Kindly suggest a possible error in code.here is my code to zip the files:
use strict;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
my $flag="Success";
my $sourceDir = 'C:/inter/';
my $destinationFile = 'C:/test/upload.zip';
my $zip = Archive::Zip->new();
Archive::Zip::setChunkSize( 2000 );
my $chunkSize = Archive::Zip::chunkSize();
my $zipped;
$zipped = $zip->addDirectory( $sourceDir );
$zipped->desiredCompressionMethod( COMPRESSION_DEFLATED);
$zipped->desiredCompressionLevel( 9 );
find(\&zip_file, $sourceDir);
$flag="Failed" unless $zip->writeToFileNamed( $destinationFile ) == AZ_OK;
$flag;
sub zip_file {
$zipped = $zip->addFile( $File::Find::name);
}
After executing above code i get a file upload.zip and when i try to unzip it using winzip it creates a folder inter and then unzip the files in that folder.
kindly help
use strict;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
my $flag="Success";
my $sourceDir = 'C:/inter/';
my $destinationFile = 'C:/test/upload.zip';
my $zip = Archive::Zip->new();
Archive::Zip::setChunkSize( 2000 );
my $chunkSize = Archive::Zip::chunkSize();
my $zipped;
$zipped = $zip->addDirectory( $sourceDir );
$zipped->desiredCompressionMethod( COMPRESSION_DEFLATED);
$zipped->desiredCompressionLevel( 9 );
find(\&zip_file, $sourceDir);
$flag="Failed" unless $zip->writeToFileNamed( $destinationFile ) == AZ_OK;
$flag;
sub zip_file {
$zipped = $zip->addFile( $File::Find::name);
}
After executing above code i get a file upload.zip and when i try to unzip it using winzip it creates a folder inter and then unzip the files in that folder.
kindly help