0
votes

I tried to use the ZipArchive framework for unzipping a zip file, but I don't understand the problem. It doesn't tell me some error, but I could not find my unzipped files/folders.

// Unzip
let sourceURL = localUrl.stringByAppendingPathComponent(path: "TEMP.zip")
let destinationURL = localUrl.stringByAppendingPathComponent(path: "TEST")
SSZipArchive.unzipFile(atPath: sourceURL, toDestination: destinationURL)

EDIT: With the answer above, here is the error message:
Error Message: Error Domain=SSZipArchiveErrorDomain Code=-1 "failed to open zip file" UserInfo={NSLocalizedDescription=failed to open zip file}

EDIT2: I checked with the function fileExists, and file is available

let str = sourceURL

let url = URL(string: str)
print(url!.path,"\n")

if FileManager.default.fileExists(atPath: url!.path) {
    print("FILE IS AVAILABLE")
} else {
    print("FILE NOT AVAILABLE")
}

Thanks in advance

Instead of using unzipFile(atPath:, toDestination:), you can use one of the methods that offer error feedback - there are ones with either pointer to error or with completion handler - mag_zbc
@mag_zbc good answer, I have an error message now... - ΩlostA
Are you sure you're using correct zip file name? I would assume both file name and extension are case sensitive. - mag_zbc
@mag_zbc name of the zip file seems good... - ΩlostA
Did you check that file actually exists? For instance, using FileManager.default.fileExists(atPath: sourceURL)? - mag_zbc