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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Archive::Zip - strange redundant empty files created

Status
Not open for further replies.

MoshiachNow

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

Using Archive::Zip on Windows- I'm experiencing some strange phenomena.
If I archive folders - everything is fine,except that if I view the resulted folder with ,say, folders F1,F2,F2 - I will see next to them empty files having the same names -F1,F2,F2 .
This cause problem copying the folders from the ZIP ,since Windows sees 2 items with the same name in the same folder ...

Will appreciate any ideas.
thanks


Long live king Moshiach !
 
How about you post your code?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
The code is :

Sub:

ZIP {
$zip->addFile("$NAME1","$NEWNAME");
}

Is called by :
&ZIP("$Foldername","$Foldername")

Thanks

Long live king Moshiach !
 
Not much to go by there.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Well.. I've never had the module do that. You should post all your code. I would probably guess the problem is the part where you get the list of files to zip. You probably submitting a directory as a file or your passing . or .. to it.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Thanks,

My code is 3000 lines ...
I do check if it's a file or dir and then use addtree or addFile respectively.

Long live king Moshiach !
 
I think what travs69 is saying that if you're testing using -d on the . and .. directories, these could be what's causing the empty files

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Thanks,
starting to get the point.
However what I'm pasing to addTree function is a dir with subdirs. So I'm checkig with "-d" if the dir exists and is a DIR,then passing it:

$zip->addTree("$NAME1","$NEWNAME");

So how can I filter out "." and ".." dirs inside the submitted dir, which possibly cause the problem ?
thanks


Long live king Moshiach !
 
Code:
if (($NAME1 ne ".") && ($NAME1 ne "..")) {
  $zip->addTree("$NAME1","$NEWNAME");
}

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Paul,
I think I'm not clear enough.
I NEVER submit "." or ".." . But these ARE inluded,naturally, in the subdirs of my DIR.
Can the "." and ".." in subdirs be an issue ?

Long live king Moshiach !
 
Yes.. if you are doing readdir or something . and .. are include by default. . = current dir and .. = dir above the dir you are in (like when you type cd .. that's how it know where to go) The code I use to ignore those are:
Code:
next if $NAME1 eq /\^.{1,2}$/;






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Thanks,

but how to use it within my code:

if (($NAME1 ne ".") && ($NAME1 ne "..")) {
$zip->addTree("$NAME1","$NEWNAME");
}


?
thanks

Long live king Moshiach !
 
You don't have to use it if you your code has that in it..
You could do what you have or



next if $NAME1 eq /\^.{1,2}$/;
$zip->addTree("$NAME1","$NEWNAME");


without the if statement around it.
If you still having problems you will need to trim your script down to just the sections that are can replicate the problem

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top