From acf81e744cf34ef45f0af0803f833c2e5c37238f Mon Sep 17 00:00:00 2001 From: Mostafa Berg Date: Thu, 9 Feb 2017 16:02:40 +0100 Subject: [PATCH] Zip.swift now sets permissions to extracted files from fileInfo, fixes issue #72 --- Zip/Zip.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Zip/Zip.swift b/Zip/Zip.swift index cd8da5e..c806b0d 100644 --- a/Zip/Zip.swift +++ b/Zip/Zip.swift @@ -145,6 +145,7 @@ public class Zip { unzGetCurrentFileInfo64(zip, &fileInfo, fileName, UInt(fileNameSize), nil, 0, nil, 0) fileName[Int(fileInfo.size_filename)] = 0 + var pathString = String(cString: fileName) guard pathString.characters.count > 0 else { @@ -190,11 +191,21 @@ public class Zip { break } } + fclose(filePointer) crc_ret = unzCloseCurrentFile(zip) if crc_ret == UNZ_CRCERROR { throw ZipError.unzipFail } + + //Set file permissions from current fileInfo + let permissions = (fileInfo.external_fa >> 16) & 0x1FF + do { + try fileManager.setAttributes([.posixPermissions : permissions], ofItemAtPath: fullPath) + } catch let error { + print("Failed to set permissions to file \(fullPath)") + } + ret = unzGoToNextFile(zip) // Update progress handler -- 2.26.2