1 (edited by Grisu 2010-07-24 17:06:33)

Topic: zrObject.ExtractFileToDisk - Unhandled Exception


I'm currently using your module to write an auto-updater for my little radio app. I think I have found 2 glitches/bugs.

When I extract all files back to disk I get the following error message that results in a crash:
"Unhandled Exception::Attempt to access field or method of Null object"

1. You get this crash if you try to extract a directory that is aready present. (I got around this by a simple check for a "." inside the filename)
2. You get this crash when the file to be extracted is already in use (prp.exe or fmod.dll)

Can you prevent these crashes somehow? These files / dirs mentioned above should just be skipped.

Example core function

Function Extract_Zip()

      Local zrObject:ZipReader = New ZipReader
      Local Extracted_file:String
      Local Scr_file:String 

      SetGadgetText(Curr_Msg_Lab,"Extracting File: ")
      If ( zrObject.OpenZip(ServerZIPFile) ) Then

      For Local i:Int=1 To zrObject.getFileCount()-1
                 Extracted_file=Replace(Scr_file,"Pocket Radio Player/","")

           If Extracted_file.find(".")>0 Then zrObject.ExtractFileToDisk(Scr_file, Extracted_file, True) <- This one!!


    End If
End Function

I can also send you a complete code for testing if needed.

Thanks in advance.

Re: zrObject.ExtractFileToDisk - Unhandled Exception

A workaround for the crash is to check each file with "openfile(file,false,true)".
If one can't open them for writing, I skip the extraction of this file.

Perhaps there's a more elegant way to solve this issue?

Re: zrObject.ExtractFileToDisk - Unhandled Exception

greetings smile  i should be able to get to the issues this evening.  if you could whip up a running example with zip files included it would be much appreciated.

Re: zrObject.ExtractFileToDisk - Unhandled Exception

greetings smile  please download the latest release as it should resolve your issues.  for an added ability to detect issues (ie file in use), ExtractFileToDisk now returns true/false based on success.

Re: zrObject.ExtractFileToDisk - Unhandled Exception

Great, seems to work so far. Got to test it more....

BtW: Is it normal that extraction of a file destroys the "timestamp"?

Re: zrObject.ExtractFileToDisk - Unhandled Exception

greetings smile  glad its all fixed up!  i had not implemented setting of the timestamp.  i have done so and uploaded a new version.  lmk how it works for you smile

Re: zrObject.ExtractFileToDisk - Unhandled Exception

Thanks for your long time support. Not many people are that dedicated. Works fine so far...

I recently discovered another smaller issue: When I extract a zip file including other zips with  filenames including German umlauts ("ä","ö","ü"), the names of the extracted files seem to be broken.

Haven't come up with a proper example code yet.

Re: zrObject.ExtractFileToDisk - Unhandled Exception

you are very welcome smile  happy that someone is getting use from my work!  the name issue is probably related to unicode support.  ZLib does not use wide chars so it will have issues with unicode characters.

Re: zrObject.ExtractFileToDisk - Unhandled Exception

I think, I'll have to live with this then. Thanks for your informations.