0

I have the following code:

   print("Zippath is "+zippath)
   print("unzippath is "+unzippath)
   print("url path is "+url.path)
   let fileManager1 = FileManager.default
   if fileManager1.fileExists(atPath: zippath) {
            print("Archive exists")
   }
   if fileManager1.isWritableFile(atPath: unzippath){
            print("dir writable")
   }
   print(SSZipArchive.unzipFile(atPath: zippath, toDestination: unzippath))
 

The output shows:

zippath is /var/mobile/Containers/Data/Application/64D975C2-66EB-4F8F-8E70-D9117AF588D4/Documents/file.csvallpics.ggg
unzippath is /var/mobile/Containers/Data/Application/64D975C2-66EB-4F8F-8E70-D9117AF588D4/Documents/unzip
url path is /var/mobile/Containers/Data/Application/64D975C2-66EB-4F8F-8E70-D9117AF588D4/Documents
Archive exists
dir writable
false

I have verified the zip file is valid by copying it to a PC and unzipping it. The unzip dir is there and is both readable and writeable. I don't understand why its not working.

After running the code, I expect to see files in the unzip directory but there isn't any.

Geoff Hackworth
  • 2,673
  • 1
  • 16
  • 16
f15radar
  • 1
  • 1
  • Is `unzippath` a file or a directory? I’m pretty sure it needs to be a directory so that the unzipped file(s) can be stored inside it. – Geoff Hackworth Mar 31 '23 at 14:51
  • Its a directory – f15radar Mar 31 '23 at 14:52
  • You could try debugging through the unzip method call to see where it fails or use a version of the method that lets you pass an error variable as a reference to get more information on why it failed. – Geoff Hackworth Mar 31 '23 at 15:30
  • I think `SSZipArchive.unzipFile` will throw on error. Are you catching that error? what is it? if it doesn't throw, pass an `error argument to this function (as `SSZipArchive.unzipFile(..., error: &error)` and see which error it returns. – timbre timbre Mar 31 '23 at 17:15
  • I get syntax errors when trying to add the error:&error. I tried following the code down and saw a 107 error but i cant seem to find out why or what exactly a 107 error is. – f15radar Apr 01 '23 at 19:01
  • Ok I found the issue, but I do not unsderstand it. Its not the unzipping, it the zipping. createzipfile randomly messes up a file everytime. I have no clue why so I guess I will look for another zip program. – f15radar Apr 02 '23 at 14:48

0 Answers0