From 9123b24e85d44c95a30dfcb154d3be2a764d5fa3 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Mon, 21 Nov 2016 19:23:27 +0300 Subject: [PATCH] ServiceInfos of Gzip and Zlib are now Equatable. --- Sources/GzipArchive.swift | 10 +++++++++- Sources/ZlibArchive.swift | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Sources/GzipArchive.swift b/Sources/GzipArchive.swift index 510d3d7d..cecd47c8 100644 --- a/Sources/GzipArchive.swift +++ b/Sources/GzipArchive.swift @@ -36,7 +36,8 @@ public class GzipArchive: Archive { static let fcomment: UInt8 = 0x10 } - struct ServiceInfo { + struct ServiceInfo: Equatable { + let magic: [UInt8] let method: UInt8 let flags: UInt8 @@ -49,6 +50,13 @@ public class GzipArchive: Archive { var fileName: String var comment: String var crc: UInt16 + + public static func ==(lhs: ServiceInfo, rhs: ServiceInfo) -> Bool { + return lhs.magic == rhs.magic && lhs.method == rhs.method && + lhs.flags == rhs.flags && lhs.mtime == rhs.mtime && lhs.extraFlags == rhs.extraFlags && + lhs.osType == rhs.osType && lhs.startPoint == rhs.startPoint && + lhs.fileName == rhs.fileName && lhs.comment == rhs.comment && lhs.crc == rhs.crc + } } static func serviceInfo(archiveData data: Data) throws -> ServiceInfo { diff --git a/Sources/ZlibArchive.swift b/Sources/ZlibArchive.swift index df26ee1d..a11c0baa 100644 --- a/Sources/ZlibArchive.swift +++ b/Sources/ZlibArchive.swift @@ -38,11 +38,20 @@ public class ZlibArchive: Archive { case slowAlgorithm = 3 } - struct ServiceInfo { + struct ServiceInfo: Equatable { + let compressionMethod: UInt8 let windowSize: Int let compressionLevel: CompressionLevel var startPoint: Int + + public static func ==(lhs: ServiceInfo, rhs: ServiceInfo) -> Bool { + return lhs.compressionMethod == rhs.compressionMethod && + lhs.windowSize == rhs.windowSize && + lhs.compressionLevel == rhs.compressionLevel && + lhs.startPoint == rhs.startPoint + } + } static func serviceInfo(archiveData data: Data) throws -> ServiceInfo {