Skip to content

Commit acf81e7

Browse files
committed
Zip.swift now sets permissions to extracted files from fileInfo, fixes issue marmelroy#72
1 parent 6f3b6b4 commit acf81e7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Zip/Zip.swift

+11
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public class Zip {
145145

146146
unzGetCurrentFileInfo64(zip, &fileInfo, fileName, UInt(fileNameSize), nil, 0, nil, 0)
147147
fileName[Int(fileInfo.size_filename)] = 0
148+
148149
var pathString = String(cString: fileName)
149150

150151
guard pathString.characters.count > 0 else {
@@ -190,11 +191,21 @@ public class Zip {
190191
break
191192
}
192193
}
194+
193195
fclose(filePointer)
194196
crc_ret = unzCloseCurrentFile(zip)
195197
if crc_ret == UNZ_CRCERROR {
196198
throw ZipError.unzipFail
197199
}
200+
201+
//Set file permissions from current fileInfo
202+
let permissions = (fileInfo.external_fa >> 16) & 0x1FF
203+
do {
204+
try fileManager.setAttributes([.posixPermissions : permissions], ofItemAtPath: fullPath)
205+
} catch let error {
206+
print("Failed to set permissions to file \(fullPath)")
207+
}
208+
198209
ret = unzGoToNextFile(zip)
199210

200211
// Update progress handler

0 commit comments

Comments
 (0)