|
Post by sbussinger on Feb 27, 2009 18:52:10 GMT -5
I have a couple of questions on the TVCLUnzip.CheckArchive function.
1) Is this function supposed to report progress using the OnTotalPercentDone? Or anywhere else? It doesn't appear to in the code but I wanted to make sure I wasn't missing something.
2) CheckArchive appears to basically be a loop testing FileIsOK for each file in the archive. But is there more to it than that? The documentation suggests that looping on FileIsOK will be much slower than CheckArchive, is that correct? (I'm obviously looking for a workaround to item 1.)
3) How good the CheckArchive function at detecting errors?
4) Can you check the integrity of a ZIP file without supplying passwords for encrypted files? It'd be nice to able to verify the file's OK without necessarily having to prompt for passwords.
Thanks!
|
|
|
Post by Kevin on Feb 27, 2009 20:11:09 GMT -5
Hi Scott, CheckArchive actually unzips every file in the archive. That is the only way to test an archive or files in the archive is by unzipping them. The unzipping is all done in memory so it is fast compared to normal unzipping to disk. Yes, the progress events are called during the CheckArchive processing. You need to have those events defined of course and have them update your progress meters. Since CheckArchive actually unzips the files it is good at detecting errors since it checks the crc of the unzipped file against the crc that is stored in the archive of the original file. CheckArchive is faster than looping through FileIsOK just because the setup overhead code is not called each time for every file. Sort of like going under water, getting all your tasks done, and then coming back up instead of coming back up for air between each task. You can't check the integrity of a zip file without supplying passwords since you have to unzip the files to check them. The password and encryption is all tied into the CRC that is created for each file. I think I answered all you questions, but let me know if I missed anything or if you need any further explanation. Thanks! Kevin
|
|
|
Post by sbussinger on Feb 28, 2009 16:25:28 GMT -5
There are a few idiosyncrasies with CheckArchive and I thought I'd leave some notes here for anyone that searches the archives.
1) You must fill in the FilesList property before calling CheckArchive. For example, "VCLUnzip1.FilesList.Add('*.*');". CheckArchive only checks files matching FilesList.
2) The OnTotalPercentDone event it not called after files that are skipped for bad passwords. While testing, I had mis-typed the password and CheckArchives skipped all the files but never called OnTotalPercentDone so it looked like it had done nothing. Works fine if the passwords are correct.
3) In the OnStartUnzip event, the FName parameter is always blank for CheckArchive. Perhaps because the files aren't really being saved anywhere? The FileIndex parameter is valid however so you can get the information you need from the FileName/PathName/FullName indexers.
|
|
|
Post by Kevin on Feb 28, 2009 21:47:24 GMT -5
There are a few idiosyncrasies with CheckArchive and I thought I'd leave some notes here for anyone that searches the archives. 1) You must fill in the FilesList property before calling CheckArchive. For example, "VCLUnzip1.FilesList.Add('*.*');". CheckArchive only checks files matching FilesList. That is strange, I'm not sure why you are experiencing this, but this is not true. Infact in CheckArchive, the DoAll property is set to True (to unzip all files) and UnZipToBufferByIndex ends up getting called and inside there, FilesList.Clear is called. What version of VCLZip are you using?This is true since OnTotalPercentDone is called during the zipping process. It is based on the number of bytes that have been unzipped compared to the total number of bytes to be unzipped. The total number of bytes to be unzipped is properly adjusted. But yes, you are right that OnTotalPercentDone is not called since no bytes were unzipped. Yes, you are correct again, FName represents the path and filename of the output file. Since CheckArchive unzips to memory there is no output path or filename. The FileIndex allows you to get to the information for the archive's internal file. Thanks for documenting these to the forum, this is just the kind of information I hope to see here. It is impossible to get everything into the help file. But I am a bit confused as to why you are needing to put something into the FilesList before calling CheckArchive? Thanks, Kevin
|
|