From a22a05fedcd136e05cb213a7d535870178c4468a Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Mon, 23 Oct 2017 20:13:40 +0300 Subject: [PATCH] Add a/c/m times to ContainerEntryInfo protocol. This also adds accessTime from NTFS extra field in ZipEntryInfo --- Sources/7-Zip/7zEntryInfo.swift | 4 ++-- .../Common/Container/ContainerEntryInfo.swift | 7 ++++++- Sources/TAR/TarEntryInfo.swift | 18 +++++++++--------- Sources/ZIP/ZipEntryInfo.swift | 13 ++++++++----- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Sources/7-Zip/7zEntryInfo.swift b/Sources/7-Zip/7zEntryInfo.swift index 4549e3ab..94d2ed3e 100644 --- a/Sources/7-Zip/7zEntryInfo.swift +++ b/Sources/7-Zip/7zEntryInfo.swift @@ -18,8 +18,6 @@ public struct SevenZipEntryInfo: ContainerEntryInfo { public let type: ContainerEntryType - // MARK: 7-Zip specific - /// Entry's last access time and date. public let accessTime: Date? @@ -29,6 +27,8 @@ public struct SevenZipEntryInfo: ContainerEntryInfo { /// Entry's last modification time and date. public let modificationTime: Date? + // MARK: 7-Zip specific + /// 7-Zip internal property which may contain UNIX permissions, type and/or DOS attributes. public let winAttributes: UInt32? diff --git a/Sources/Common/Container/ContainerEntryInfo.swift b/Sources/Common/Container/ContainerEntryInfo.swift index b86f6dd1..738d7828 100644 --- a/Sources/Common/Container/ContainerEntryInfo.swift +++ b/Sources/Common/Container/ContainerEntryInfo.swift @@ -13,7 +13,12 @@ public protocol ContainerEntryInfo { var size: Int? { get } - // TODO: a/c/m times. + var accessTime: Date? { get } + + var creationTime: Date? { get } + + var modificationTime: Date? { get } + // TODO: uncompressed and compressed sizes? } diff --git a/Sources/TAR/TarEntryInfo.swift b/Sources/TAR/TarEntryInfo.swift index 61211371..ecb05edd 100644 --- a/Sources/TAR/TarEntryInfo.swift +++ b/Sources/TAR/TarEntryInfo.swift @@ -18,18 +18,18 @@ public struct TarEntryInfo: ContainerEntryInfo { public let type: ContainerEntryType + /// The most recent access time of the original file or directory (PAX only). + public let accessTime: Date? + + /// The creation time of the original file or directory (PAX only). + public let creationTime: Date? + + /// The most recent modification time of the original file or directory. + public let modificationTime: Date? + // MARK: TAR specific public let permissions: Permissions - - /// The most recent access time of the original file or directory (PAX only). - public let accessTime: Date? - - /// The most recent modification time of the original file or directory. - public let modificationTime: Date - - /// The creation time of the original file or directory (PAX only). - public let creationTime: Date? /// Owner's ID. public let ownerID: Int? diff --git a/Sources/ZIP/ZipEntryInfo.swift b/Sources/ZIP/ZipEntryInfo.swift index 40a7a93d..1d78af9a 100644 --- a/Sources/ZIP/ZipEntryInfo.swift +++ b/Sources/ZIP/ZipEntryInfo.swift @@ -19,13 +19,15 @@ public struct ZipEntryInfo: ContainerEntryInfo { public let type: ContainerEntryType - // MARK: ZIP specific - - // TODO: Describe preference of various fields when setting this property. - public let modificationTime: Date? + // TODO: Describe preference of various fields when setting time properties. + public let accessTime: Date? public let creationTime: Date? + public let modificationTime: Date? + + // MARK: ZIP specific + public let comment: String public let externalFileAttributes: UInt32 @@ -72,8 +74,9 @@ public struct ZipEntryInfo: ContainerEntryInfo { hour: hours, minute: minutes, second: seconds).date } - // NTFS Creation Time from extra fields. + // NTFS Access and Creation times from extra fields. self.creationTime = Date(from: cdEntry.ntfsCtime) + self.accessTime = Date(from: cdEntry.ntfsAtime) // Size self.size = Int(cdEntry.uncompSize)