From 78fd83dda23546b4685cc09bb4542e0d627520fc Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Fri, 9 Dec 2016 01:08:49 +0300 Subject: [PATCH] Adopted removal of alignedBytes() in other code. --- Sources/Deflate.swift | 6 ++++-- Sources/GzipArchive.swift | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) 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)