diff --git a/Sources/Deflate.swift b/Sources/Deflate.swift index db22df3d..6f6e2075 100644 --- a/Sources/Deflate.swift +++ b/Sources/Deflate.swift @@ -69,8 +69,10 @@ public class Deflate: DecompressionAlgorithm { guard length & nlength == 0 else { throw DeflateError.WrongBlockLengths } // Process uncompressed data into the output // TODO: Replace precondition with guard and error throwing. - precondition(pointerData.bitShift == 0, "Misaligned byte.") - out.append(contentsOf: pointerData.alignedBytes(count: length)) + precondition(pointerData.bitMask == 1, "Misaligned byte.") + for _ in 0.. ServiceInfo { // First two bytes should be correct 'magic' bytes - let magic = pointerData.alignedBytes(count: 2) - guard magic == [31, 139] else { throw GzipError.WrongMagic } + let magic = pointerData.intFromBits(count: 16) + guard magic == 0x1f8b else { throw GzipError.WrongMagic } // Third byte is a method of compression. Only type 8 (DEFLATE) compression is supported let method = pointerData.alignedByte() @@ -75,7 +75,7 @@ public class GzipArchive: Archive { var serviceInfo = ServiceInfo(magic: magic, method: method, flags: pointerData.alignedByte(), - mtime: pointerData.alignedBytes(count: 4), + mtime: pointerData.intFromBits(count: 32), extraFlags: pointerData.alignedByte(), osType: pointerData.alignedByte(), fileName: "", comment: "", crc: 0)