Archive::Zip - case sensitivity help

Discussion in 'Perl Misc' started by MoshiachNow, Dec 13, 2006.

  1. MoshiachNow

    MoshiachNow Guest

    HI,

    Using this module on Windows,I ran into a very serious problem.

    The files/folders fail to zip/unzip if on the letters in path has a
    different case (like on different SW versions of the product I'm trying
    to backup).Ex:

    Path "Prinergy\CreoAraxi\data" specified for Zipping will not
    zip/unzip properly,if physically on the FS it appears as
    "Prinergy\CreoAraxi\Data".

    I have to find a way to make the module be not case sensitive,since I
    can not predict the case on my different product versions.
    Thanks
    MoshiachNow, Dec 13, 2006
    #1
    1. Advertising

  2. MoshiachNow

    AC Guest

    "MoshiachNow" <> wrote in message
    news:...
    > HI,
    >
    > Using this module on Windows,I ran into a very serious problem.
    >
    > The files/folders fail to zip/unzip if on the letters in path has a
    > different case (like on different SW versions of the product I'm trying
    > to backup).Ex:
    >
    > Path "Prinergy\CreoAraxi\data" specified for Zipping will not
    > zip/unzip properly,if physically on the FS it appears as
    > "Prinergy\CreoAraxi\Data".
    >
    > I have to find a way to make the module be not case sensitive,since I
    > can not predict the case on my different product versions.
    > Thanks
    >


    I ran into this too. I use the brute force method. I iterate over the member
    names and do a lower case comparison against the candidate member name to
    find the real member name, then use that in all subsequent method calls.

    sub FindZipEntryName
    {
    my ($zip,$member) = @_;

    $member =~ s/\\/\//g; # archive paths are Perl-style, not Windows
    my $memberq = quotemeta($member);

    # the extract method considers file names as CASE-SENSITIVE, so
    # we need to look it up

    my @members = $zip->memberNames();

    foreach my $mem (@members)
    {
    if ($mem =~ /^$memberq$/i)
    {
    return $mem;
    }
    }

    return $member;
    }

    Hope this helps.

    Allan
    AC, Dec 13, 2006
    #2
    1. Advertising

  3. MoshiachNow

    MoshiachNow Guest

    Thanks,will check your code later.
    For now ,since my problem is with directories only,not files,solved the
    issue by getting DOS to tell me the right path:

    if ($NAME =~ /\\/) { #it's a dir,check case !
    chdir("$NAME");
    #get the real Path :
    $NAME=`dir|find \"Directory of\"`;chomp $NAME;
    $NAME =~ s/.*(\w\:.*)/$1/; #remove text
    }
    MoshiachNow, Dec 14, 2006
    #3
  4. MoshiachNow

    Alan Stewart Guest

    On 14 Dec 2006 02:45:29 -0800, "MoshiachNow" <>
    wrote:

    >Thanks,will check your code later.
    >For now ,since my problem is with directories only,not files,solved the
    >issue by getting DOS to tell me the right path:
    >
    >if ($NAME =~ /\\/) { #it's a dir,check case !
    > chdir("$NAME");
    > #get the real Path :
    > $NAME=`dir|find \"Directory of\"`;chomp $NAME;
    > $NAME =~ s/.*(\w\:.*)/$1/; #remove text
    >}


    You could use:

    Win32::GetLongPathName()

    Feed it any case long or short (8.3) name and you get back the actual
    case-correct long name. Same thing with:

    Win32::GetShortPathName()



    Alan
    Alan Stewart, Dec 15, 2006
    #4
  5. MoshiachNow

    MoshiachNow Guest

    Alan Stewart wrote:

    > Feed it any case long or short (8.3) name and you get back the actual
    > case-correct long name. Same thing with:
    >
    > Win32::GetShortPathName()
    >
    >
    >
    > Alan


    Thanks,Alan

    Great help !
    MoshiachNow, Dec 17, 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:
    531
    A. Sinan Unur
    Jan 11, 2004
  2. Twig
    Replies:
    1
    Views:
    126
    A. Sinan Unur
    Jan 27, 2006
  3. MoshiachNow
    Replies:
    2
    Views:
    269
    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:
    165
  5. Bo Yang
    Replies:
    9
    Views:
    297
    -berlin.de
    Nov 20, 2006
Loading...

Share This Page