Skip to content

Commit

Permalink
Try adding back directoryAttributes
Browse files Browse the repository at this point in the history
  • Loading branch information
fpseverino committed Oct 2, 2024
1 parent 668236f commit 76f1c5a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
3 changes: 0 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import FoundationEssentials

let package = Package(
name: "Zip",
platforms: [
.macOS(.v11),
],
products: [
.library(name: "Zip", targets: ["Zip"])
],
Expand Down
23 changes: 20 additions & 3 deletions Sources/Zip/Zip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,29 @@ public class Zip {
throw ZipError.unzipFail
}

let creationDate = Date()
let directoryAttributes: [FileAttributeKey: Any]?
#if (os(Linux) || os(Windows)) && compiler(<6.0)
directoryAttributes = nil
#else
directoryAttributes = [
.creationDate: creationDate,
.modificationDate: creationDate
]
#endif

do {
if isDirectory {
try FileManager.default.createDirectory(atPath: fullPath, withIntermediateDirectories: true)
try FileManager.default.createDirectory(
atPath: fullPath,
withIntermediateDirectories: true,
attributes: directoryAttributes)
} else {
let parentDirectory = (fullPath as NSString).deletingLastPathComponent
try FileManager.default.createDirectory(atPath: parentDirectory, withIntermediateDirectories: true)
try FileManager.default.createDirectory(
atPath: (fullPath as NSString).deletingLastPathComponent,
withIntermediateDirectories: true,
attributes: directoryAttributes
)
}
} catch {}
if FileManager.default.fileExists(atPath: fullPath) && !isDirectory && !overwrite {
Expand Down

0 comments on commit 76f1c5a

Please sign in to comment.