#692360 extractMemberWithoutPaths: wrong manpage or wrong behaviour

#692360#5
Date:
2012-11-05 11:36:21 UTC
From:
To:
The manpage of Archive::Zip states:

   extractMemberWithoutPaths( $memberOrName [, $extractedName ] )

   Extract the given member, or match its name and extract it.  Does not use path information
   (extracts into the current directory). Returns undef if member doesn't exist in this Zip.  If
   optional second arg is given, use it as the name of the extracted member (its paths will be
   deleted too). Otherwise, the internal filename of the member (minus paths) is used as the name of
   the extracted file or directory. Returns "AZ_OK" on success.

It's not true. If you pass a pathname as the second argument

    - the leading directories(!) are created (should be noted in the man page, as
      from my POV it's not common in the unix world.)

    - the pathname is used as the name for the extracted file

The man page states, that paths will be removed too from the second
argument.

I'm not sure how to solve the problem. It could be fixed easily around
line 202ff in Archive/Zip/Archive.pm, but I'd be afraid that this could
break existing applications (at least mine ☺)

Here is some code to reproduce the behaviour:

    #! /usr/bin/perl
    use 5.010;
    use strict;
    use warnings;
    use Archive::Zip;

    my $DIR = "/tmp/$$.d/Xtract/";

    my $zipfile = shift // die "need name of zip file\n";
    my $zip = new Archive::Zip $zipfile or die "Archive::Zip $zipfile: $!\n";

    foreach my $member ($zip->members) {
        say $member->fileName;
        $zip->extractMemberWithoutPaths($member, "$DIR/$name");
    }

    system "find $DIR/ -ls";

#692360#12
Date:
2012-11-24 16:19:17 UTC
From:
To:
Hi Heiko
coorect (btw, in your example there was a missing assignment for
$name?).

I have forwarded this upstream. *big* warning: I'm not sure if it's
enough with the attached patch already. I only did a quick look right
now.

Regards,
Salvatore