From f95b8116f272b7a022b11ecddd59daafed757f4e Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Wed, 21 Feb 2018 23:14:44 +0300 Subject: [PATCH] [ZIP] Add public API for accessing uid and gid These APIs are: ZipEntryInfo.ownerID and groupID (named for consistency with TarEntryInfo). --- Sources/ZIP/ZipEntryInfo.swift | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Sources/ZIP/ZipEntryInfo.swift b/Sources/ZIP/ZipEntryInfo.swift index 0b4adcee..e7e86dda 100644 --- a/Sources/ZIP/ZipEntryInfo.swift +++ b/Sources/ZIP/ZipEntryInfo.swift @@ -74,6 +74,24 @@ public struct ZipEntryInfo: ContainerEntryInfo { /// Entry's compression method. public let compressionMethod: CompressionMethod + /** + ID of entry's owner. + + Set from different sources in the following preference order, if possible: + 1. Info-ZIP New Unix extra field. + 2. Info-ZIP Unix extra field. + */ + public let ownerID: Int? + + /** + ID of the group of entry's owner. + + Set from different sources in the following preference order, if possible: + 1. Info-ZIP New Unix extra field. + 2. Info-ZIP Unix extra field. + */ + public let groupID: Int? + let cdEntry: ZipCentralDirectoryEntry let localHeader: ZipLocalHeader @@ -174,6 +192,12 @@ public struct ZipEntryInfo: ContainerEntryInfo { // Compression method. self.compressionMethod = CompressionMethod(localHeader.compressionMethod) + + // Owner's ID. + self.ownerID = localHeader.infoZipNewUid ?? localHeader.infoZipUid?.toInt() + + // Owner's group ID. + self.groupID = localHeader.infoZipNewGid ?? localHeader.infoZipGid?.toInt() } }