Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Archive::Zip - case sensitivity help !!!

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Joined
Feb 6, 2002
Messages
1,851
Location
IL
HI,

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

The files/folders fail to zip/unzip if on the letters in path has a differnt 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 size on different product versions.
Thanks

Long live king Moshiach !
 
Where do you get the file/dir names you're unzipping? That would be useful for coming up with a solution.
 
Also, does the case of "Prinergy\CreoAraxi" change case too, or does that stay constant?
 
ishnid,

1.The paths I hard code into my Perl script,after checking them on severall target systems.But now I got surprise ...
2.So far Prinergy\CreoAraxi is not supposed to change,only the "data/Data" string.

I know how to fix this,by first browsing the real FS "Prinergy\CreoAraxi" dir,checking for a real "data" casing.
But I realy want a solution of somehow making Archive"::ZIP case unsensitive...maybe it's impossible.
Thanks

Long live king Moshiach !
 
I would imagine that it would be easier to just come up with a hack yourself than trying to mess with Archive::Zip (which is a pretty complex set of modules) to make it case-insensitive.

If it really is only the data/Data directory that can change, you could just check for the existence of each and add the appropriate one:
Code:
if ( -e 'Prinergy\CreoAraxi\Data' ) {
   $zip->addDirectory( 'Prinergy\CreoAraxi\Data' );
}
elsif ( -e 'Prinergy\CreoAraxi\data' ) {
   $zip->addDirectory( 'Prinergy\CreoAraxi\data' );
}

Alternatively, if this is going to happen a few times, you could possibly do something like this (sample code only):
Code:
use File::Find;

# set up your $zip object

# dirs to zip
my %to_zip = (
   '.\prinergy\creoaraxi\data' => 1,
   '.\prinergy\creoaraxi\bin' => 1,
   '.\prinergy\creoaraxi\images' => 1
);

find( sub {
   $zip->addDirectory( $File::Find::name ) if ( $to_zip{ lc $File::Find::name} );
}, '.' );

I haven't tested that code but hopefully you get the idea. The plan is to have a hash containing the lowercase versions of everything you want to include in your zip file. When traversing through the file structure with File::Find, if you find anything whose lowercase version (effectively a case-insensitive match) is in the hash, add it to the zip file. If not, don't. Just an idea in the absence of finding anything in Archive::Zip's own docs that suggest it can be made case-insensitive.
 
HI,

What I actually need is a way to get the whole path in the right casing , not just it's trail.I may never know where in the path the casing may change.
Do we not have some utility in Perl to get the real Windows path ?

Thanks

Long live king Moshiach !
 
I can't tell you for sure. I'm only a very occasional Windows user.

The second chunk of code I posted checks the entire path in a case-insensitive way. Is that not what you're looking for?
 
ishnid,

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
}


Long live king Moshiach !
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top