2

Does anyone know a way to detect if a zip file has a pasword set when trying to unzip with the library ZipArchive?

The code:

[zip UnzipOpenFile:unzipFilename Password:zipPassword] 

will:

  • unzip files with a password when zipPassword is set.

  • unzip files without a password when zipPassword is nil

BUT

if directing a user to select a zip file I need to know whether to prompt the user for a password if the zip file has one otherwise all files in the zip are created but with zero length.

Seems messy to do this, check for zero length and if so prompt user for password for another try?

Surely there must be a way to tell if the zip file in question has a password?

DShah
  • 9,768
  • 11
  • 71
  • 127
user7865437
  • 812
  • 14
  • 28

1 Answers1

0

I am using ZipArchive utility to import zipped file in Objective C application. Part of the code is

if ([za UnzipOpenFile:[url path] Password:@"XYZ"]){

     BOOL ret = [za UnzipFileTo: documentsDirectory overWrite: YES];

I find that my password protected zipped file gets unzipped by above code even without using a password ( using [za UnzipOpenFile:[url path]] ) or even when a wrong password as above is given.

The zipped file was created using zip -e option on Mac. Is there any flag that needs to be set up to make password detection work ?

andrewsi
  • 10,807
  • 132
  • 35
  • 51