Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

monsterzero's scratchpad

by monsterzero (Monk)
on Jun 14, 2006 at 23:24 UTC ( #555382=scratchpad: print w/ replies, xml ) Need Help??

Here is some code for zip file
use strict; use warnings; use File::Spec; use Win32::DriveInfo; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); my $tmpdir = File::Spec->tmpdir(); print "Please supply the file that was downloaded:\n"; chop( my $file_input = <STDIN> ); print "Checking file: $file_input\n"; #check if the files exists if ( -e $file_input && -r $file_input ) { print "Good the file is there and I can read it\n"; } else { die "File $file_input does not exist\n"; } print "Computing extracted size for $file_input \n"; my $file_size = compute_file_size($file_input); my ( $volume, undef, undef ) = File::Spec->splitpath($tmpdir); my $TotalNumberOfFreeBytes = ( Win32::DriveInfo::DriveSpace("$volume") + )[6]; if ( $TotalNumberOfFreeBytes < $file_size ) { print "Not enought space on $volume drive to extract files\n"; die; } else { print "There is enought room to extract the files\n"; } print "Extracting files to $tmpdir\\mpupdate\n"; extract_file($file_input, $tmpdir); sub extract_file { my ($filename, $dir) = @_; my $zip = Archive::Zip->new($filename); my ($volume,$directories ) = File::Spec->splitpath( $dir, 1 ); my $new_dir = File::Spec->catdir( ("$directories", "mpupdate") ); $new_dir .="\\"; my $status = $zip->read( $filename ); die "Read of $filename failed\n" if $status != AZ_OK; $zip->extractTree('', "$new_dir","$volume"); return; } sub compute_file_size { my ($filename) = @_; my $size; my $zip = Archive::Zip->new($filename); foreach my $file ( $zip->members ) { $size += $file->uncompressedSize(); } return ($size); }
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2016-07-02 08:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?


















    Results (19 votes). Check out past polls.