Skip to content

Commit

Permalink
Try fix permission on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
fpseverino committed Sep 9, 2024
1 parent 4b68f84 commit b3a50b8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Sources/Zip/Zip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,20 @@ public class Zip {

// Set file permissions from current `fileInfo`
if fileInfo.external_fa != 0 {
// TODO: Set permissions properly on Windows
#if os(Windows)
try FileManager.default.setAttributes([.posixPermissions: 0o700], ofItemAtPath: fullPath)
#else
let permissions = (fileInfo.external_fa >> 16) & 0x1FF
// We will define a valid permission range between Owner read only to full access
if permissions >= 0o400 && permissions <= 0o777 {
do {
// TODO: Set permissions properly on Windows
#if os(Windows)
try FileManager.default.setAttributes([.posixPermissions: 0o700], ofItemAtPath: fullPath)
#else
try FileManager.default.setAttributes([.posixPermissions: permissions], ofItemAtPath: fullPath)
#endif
} catch {
print("Failed to set permissions to file \(fullPath), error: \(error)")
}
}
#endif
}

ret = unzGoToNextFile(zip)
Expand Down

0 comments on commit b3a50b8

Please sign in to comment.