PDA

View Full Version : Existing Issues with Zip.Add


SRJ
06-26-2004, 11:23 PM
Hey all,

I've just spent the greater part of the day discovering some issues with the Zip.Add function. For those who are unaware of the weird things that happen with the Zip.Add function, heres a summary:

1. Store pathnames will only store relative pathnames not absolute. From trawling through the forum I've discovered this was changed between v5.0.0.3 and v5.0.0.4. It can be worked around if you're after absolute filenames but only when you're extracting. Might be easier to replace this functionality thus making it comparable with WinZip etc.
2. It will not archive/compress any file whose attribute is set to 'Hidden'. Haven't tested this with the 'System' attribute but believe it might also miss these.
3. As stated elsewhere in the forums, the Filename variable that the Zip.Add function passes to the callback function, contains information which is undocumented. The information passed occurs in the following order:

Processing Item List... Please wait.
Item 1 of 20
Item 2 of 20
Viper/040627 - 122401.zip
etc...

Obviously, the no. of items will depend on how many files and directories you are archiving. Yep, you saw it, the max count (in the example this is 20) also includes any recursed directories!!! In my example, there was 1 directory and 19 files (although the directory did contain another 2 hidden files).

Wonder how I came across these? Essentially, to count the number of files processed and update them via a call back function, you need to know how many files you are processing to begin with. The easiest way to do this was via the File.Find function. Note, though, that this function includes ALL files (yep, hidden ones etc) and directories if you tell it too. So if you count the files in this table using Table.Count your figure will be different than that calculated by the Zip.Add function.

If you're interested, I finally wrote this bit of code to strip the current file out of the Filename variable that is passed to the callback function. Although the answer is pretty straight forward, it wasn't easy to get to!


-- UpdateProgress function
function UpdateProgress(Filename, Percent)
if String.Compare(String.Left(Filename,4), "Item") == 0 then
CurrentFile = String.ToNumber(String.Mid(Filename,6,2));
else
CurrentFile = nil
end
if CurrentFile ~= nil then
Label.SetText("Label5", "Overall File Progress... ("..CurrentFile.."/"..TotalFiles..")");
end
end

Next thing I'll do is add the code to strip the max. file count and use it instead of File.Find and Table.Count. THat way, TotalFiles (see code above), will be accurate.

Hope this helps all!

SRJ.

Corey
06-26-2004, 11:45 PM
Nice post! :)

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)