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

Discussion in 'Perl Misc' started by MoshiachNow, Oct 4, 2006.

  1. MoshiachNow

    MoshiachNow Guest

    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
    MoshiachNow, Oct 4, 2006
    #1
    1. Advertising

  2. MoshiachNow

    Paul Lalli Guest

    MoshiachNow wrote:
    > 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
    Paul Lalli, Oct 4, 2006
    #2
    1. Advertising

  3. MoshiachNow

    MoshiachNow Guest


    > 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
    MoshiachNow, Oct 5, 2006
    #3
  4. MoshiachNow

    Paul Lalli Guest

    MoshiachNow wrote:
    > > Please post a SHORT but COMPLETE script that demonstrates your errors.

    ^^^^^^^^

    > 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
    Paul Lalli, Oct 5, 2006
    #4
  5. MoshiachNow <> wrote:

    > &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...


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Oct 5, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Graham Wood
    Replies:
    3
    Views:
    540
    A. Sinan Unur
    Jan 11, 2004
  2. Twig
    Replies:
    1
    Views:
    129
    A. Sinan Unur
    Jan 27, 2006
  3. MoshiachNow
    Replies:
    2
    Views:
    273
    Ilya Zakharevich
    Oct 4, 2006
  4. MoshiachNow

    Archive::Zip - zip file has "invalid" format

    MoshiachNow, Oct 5, 2006, in forum: Perl Misc
    Replies:
    1
    Views:
    167
  5. Bo Yang
    Replies:
    9
    Views:
    301
    -berlin.de
    Nov 20, 2006
Loading...

Share This Page