isZipFile

Sep 8, 2009 at 6:52 PM

 

how far does this go to deturmine if the file is really a zip? can it catch the situation where someone takes a regular file and changes the extension to .zip? can it detect if the file has 0 bytes in it? the situation with 0 bytes was an issue with DynaZip i believe when it tried to extract. im trying to avoid the same problems. i see there is a test extract option. for really large files, is this process shortened somehow by canceling the extract or by another method?

Coordinator
Sep 8, 2009 at 8:16 PM
Edited Sep 8, 2009 at 8:17 PM

To understand how IsZipFile() works, I suggest you Read the doc

A zero byte file is not a zipfile and this method will indicate as much.  

a regular file with the extension changed is also not a zipfile and IsZipFile() will again return False.

This is easy for you to test.

The text extract actually extracts the files into a null stream.  The process is shortened because the output files are not written to a filesystem, so there is no IO.  But, all the decompression happens, and the checksum verification happens.  This can take some time for large files, even without the IO.   This does not work with an encrypted zip file.  If you want to verify an encrypted zip file, you will have to do it on your own.

 

Sep 8, 2009 at 10:39 PM
Edited Sep 8, 2009 at 10:48 PM

if you read the previous before i edited disregard. ill retest the same case