Posted on 2006-01-19 21:59:42-08 by jolustig
'Illegal Seek' - from Archive::Zip?
I am generating an auto-extracting windows zip using Archive::Zip on Solaris. The downloaded files work fine but an 'Illegal Seek' is generated each time and I'm trying to clean up the code. Here's what I believe to be the offending code: -------------------------------
sub writeZipFusionFile { my ( $builder, @fileobjects ) = @_; my $zip = Archive::Zip->new(); my $ztempfile = "$configdir$sessionId.zip"; my $zh = new IO::File($ztempfile, 'w') or die "can't create IO::File object for $ztempfile : $!"; my $memberFile; if ( $builder ){ $memberFile = $zip->addFile("$setup_path","setup.exe"); $memberFile->desiredCompressionLevel(6); my $time = time(); my $port = $ENV{REMOTE_PORT}; my $config_file = $configdir . $time . $port . "config.txt"; open(CONFIG,">$config_file") or warn("Can't open config file $config_file") && die_gracefu +lly; print CONFIG "filename::sb_fullpres.ppt\r\n"; print CONFIG "beginfiles\r\n"; foreach my $file( @fileobjects ){ my $ppt; my $location = $presodir . "/" . $file->{location}; eval { $ppt = getPPTFromDir( $location );}; die_gracefully && warn($@) if ($@); print CONFIG "$file->{file_name}\r\n"; warn("user $user adding file $file->{file_id}"); $memberFile = $zip->addFile($ppt,$file->{file_name}) || warn("$user Can't add file $file->{file_id}"); $memberFile->desiredCompressionLevel(6) || warn("$user Can't set compression for $file->{file_id}"); push(@file_ids,$file->{file_id}); } print CONFIG "endfiles\r\n"; close CONFIG; warn("adding stitcher config file : $config_file"); $memberFile = $zip->addFile("$config_file","config.txt") || warn("$user can't add stitcher config file"); $memberFile->desiredCompressionLevel(6); warn("adding zipfusion config file"); $memberFile = $zip->addFile('./builder.zfc',"\[SFX\]Config.zfc") || warn("$user can't add zipfusion config file : $!"); #$memberFile = $zip->addFile($logo,"\[SFX\]logo.wmf") || #warn("$user can't add zipfusion logo file : $!"); my $result = $zip->writeToFileHandle($zh); die_gracefully( "can't write zip to file $zh: $result" ) unless ($result == 0); unlink $config_file; } else { foreach my $file( @fileobjects ){ my $ppt; my $location = $presodir . "/" . $file->{location}; eval { $ppt = getPPTFromDir( $location );}; die_gracefully($@) if ($@); warn("user $user adding file $file->{file_id}"); $memberFile = $zip->addFile($ppt,$file->{file_name}) || warn("$user Can't add file $file->{file_id}"); $memberFile->desiredCompressionLevel(6) || warn("$user Can't set compression for $file->{file_id}"); push(@file_ids,$file->{file_id}); } warn "added lib file to zip. zip members : ", $zip->memberNames(); $memberFile = $zip->addFile('./library.zfc',"\[SFX\]Config.zfc") || warn("$user can't add zipfusion config file"); my $result = $zip->writeToFileHandle($zh); die_gracefully( "can't write zip to file $zh: $result" ) unless ($result == 0); warn "added zipfusion config to zip. zip members : ", $zip->memberNames(); } undef $zh; my $xtempfile = "$configdir$sessionId.exe"; open EXE,">$xtempfile" or die("Can't open $xtempfile for writing : $!"); open STUB,"<zf" or die("Can't open zipfusion stub for reading : $!"); foreach(<STUB>){ print EXE; } open ZIPTEMP, "<$ztempfile" or die("Can't open $ztempfile for reading : $!"); foreach(<ZIPTEMP>){ print EXE; } close ZIPTEMP; unlink $ztempfile; close EXE; warn ("zip -A results : ", `/usr/local/bin/zip -A $xtempfile`); return $xtempfile; }
------------------------------- Any suggestions? Jon
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.