From 1bc2c46936ecfbc6848fa991ac8acd756edf268c Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Mon, 24 Oct 2016 20:21:38 +0300 Subject: [PATCH] Added code to process uncompressed blocks. --- Sources/Deflate.swift | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Sources/Deflate.swift b/Sources/Deflate.swift index 5cd5b0f4..6ace8ca5 100644 --- a/Sources/Deflate.swift +++ b/Sources/Deflate.swift @@ -25,10 +25,10 @@ extension UInt8 { } - public enum DeflateError: Error { case WrongMagic case UnknownCompressionMethod + case WrongBlockLengths } public class Deflate { @@ -107,12 +107,23 @@ public class Deflate { print("\(crc)") } + var index = startPoint while true { - let isLastBit = data.byte(at: startPoint)[0] - let blockType = data.byte(at: startPoint)[1..<3] + let isLastBit = data.byte(at: index)[0] + let blockType = data.byte(at: index)[1..<3] + + let align = 3 if blockType == [0, 0] { // Uncompressed - + let lengthArray = data.bytes(from: index..