Archive::Zip - case sensitivity help


M

MoshiachNow

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
 
Ad

Advertisements

A

AC

MoshiachNow said:
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
 
M

MoshiachNow

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
}
 
A

Alan Stewart

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
 
Ad

Advertisements

M

MoshiachNow

Alan said:
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 !
 

Top