Archive::Zip - end up with empty file ...

M

MoshiachNow

HI,

The code looks like:

my $fh = IO::File->new ("out.zip","w");
$zip->addFileOrDirectory($NAME);
$zip->addFileOrDirectory($NAME1);
$zip->addFileOrDirectory($NAME2);
..
..
$zip->writeToFileHandle ($fh);

I end up with empty file ...
Appreciate any ideas.
Thanks
 
P

Paul Lalli

MoshiachNow said:
The code looks like:

my $fh = IO::File->new ("out.zip","w");
$zip->addFileOrDirectory($NAME);
$zip->addFileOrDirectory($NAME1);
$zip->addFileOrDirectory($NAME2);
.
.
$zip->writeToFileHandle ($fh);

Where did $zip come from?
Where did $NAME, $NAME1, $NAME2 come from?
What are the return values of all the addFileOrDirectory calls?

Please post a SHORT but COMPLETE script that demonstrates your errors.

Paul Lalli
 
M

MoshiachNow

Where did $zip come from?
Where did $NAME, $NAME1, $NAME2 come from?
What are the return values of all the addFileOrDirectory calls?

Please post a SHORT but COMPLETE script that demonstrates your errors.

Paul Lalli

Ok,The script on my Windows looks as following. I chdir to the
directory where all my files and folders to be zipped exist.Then I'm
calling a procedire ZIP as following :


&ZIP("Marksets ");
&ZIP("PrintConsole.reg");
.. . .

sub ZIP {
$NAME=shift;
$NEWNAME=shift;
warn "error zipping $NAME !!! $!" unless
$zip->addFileOrDirectory("$NAME") == AZ_OK;
}

The warning I get look like:
error zipping Marksets !!! at script/rehost.pl line 2159.
error zipping PrintConsole.reg !!! Bad file descriptor at
script/rehost.pl line 2159.
error zipping KDI-PGY2500_SysInfo.nfo !!! Bad file descriptor at
script/rehost.pl line 2159.
error zipping OS_PRINTERS !!! Bad file descriptor at script/rehost.pl
line 2159.
error zipping D:\Documents and
Settings\Administrator\Desktop\KDI-PGY2500_20061005_P3102_rehostsave.txt
!!! Bad file descriptor at script/rehost.pl line 2159.

(line 2159 is the one with the $zip->addFileOrDirectory("$NAME") ).

The zip file holds all files and folders,however all folders are empty.
Thanks
 
P

Paul Lalli

MoshiachNow said:
^^^^^^^^

warn "error zipping $NAME !!! $!" unless
$zip->addFileOrDirectory("$NAME") == AZ_OK;

I see nothing in the docs for Archive::Zip that indicates $! is set on
a failure. Print out the return value of the method, and compare it to
the values listed in the documentation. That will tell you what the
problem is.

Paul Lalli
 
T

Tad McClellan

MoshiachNow said:
&ZIP("Marksets "); ^
^
warn "error zipping $NAME !!! $!" unless ^
^
error zipping Marksets !!! at script/rehost.pl line 2159.
^^^

How come there is not 2 spaces there?

Either this is not your actual code, or that is not the actual message...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top