0

I have used ZipArchiver to unzip and it is working fine. But when it receives empty zip file, it goes error callback.

ZipArchive *za = [[ZipArchive alloc] init];

if ([za UnzipOpenFile: zipFilePath]) {

    //Valid zip file code goes here.

}else {

    //Unable to open zip file. May be empty or corrupted.
}

Is there any method to check a zip is really empty or just unzip error. A Boolean value return will be most suitable solution.

Edit 1: I need a method to check a zip has any files or its just empty files.

Edit 2 : As mentioned by @iphonic, we cannot relay on size of a empty zip file. It simply cannot be zero. In my case, I got 22Bytes for empty zip file size.

Eric Aya
  • 68,765
  • 33
  • 165
  • 232
byJeevan
  • 3,240
  • 2
  • 33
  • 54
  • You are already checking it, whats the problem? – iphonic Apr 19 '17 at 08:20
  • If in the path `zipFilePath` has valid empty zip file then it goes to error callback. Same error callback also called if the zip file is corrupter/invalid . So please tell me @iphonic how do i differentiate these 2 cases ? Thanks any way for your reply. – byJeevan Apr 19 '17 at 08:22
  • An Empty Zip file is considered as corrupt file, it can't be opened so the error, it is generalized error. Since you want to check file size try [this solution](http://stackoverflow.com/a/8844138/790842) – iphonic Apr 19 '17 at 08:24
  • Possible duplicate of [Finding file's size](http://stackoverflow.com/questions/5743856/finding-files-size) – iphonic Apr 19 '17 at 08:25
  • No brother, it cannot be a zero file size. I got 22bytes. We cannot compare with file size and decide empty zip file. – byJeevan Apr 19 '17 at 09:00

0 Answers0