From dd7f4b2fc88fb9a5d699e69148a02cf09999e1fd Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Thu, 9 Nov 2017 19:39:34 +0300 Subject: [PATCH] Add isEncryptionMethod property to 7zCoder and use it in 7zFolder --- Sources/7-Zip/7zCoder.swift | 2 ++ Sources/7-Zip/7zFolder.swift | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/7-Zip/7zCoder.swift b/Sources/7-Zip/7zCoder.swift index 4da245d2..b8f0e047 100644 --- a/Sources/7-Zip/7zCoder.swift +++ b/Sources/7-Zip/7zCoder.swift @@ -13,6 +13,7 @@ class SevenZipCoder { let id: [UInt8] let compressionMethod: CompressionMethod + let isEncryptionMethod: Bool let numInStreams: Int let numOutStreams: Int @@ -31,6 +32,7 @@ class SevenZipCoder { let id = bitReader.bytes(count: idSize) self.id = id compressionMethod = CompressionMethod(id) + isEncryptionMethod = id[0] == 0x06 numInStreams = isComplex ? bitReader.szMbd() : 1 numOutStreams = isComplex ? bitReader.szMbd() : 1 diff --git a/Sources/7-Zip/7zFolder.swift b/Sources/7-Zip/7zFolder.swift index 59ac4ba7..c1f9dc3a 100644 --- a/Sources/7-Zip/7zFolder.swift +++ b/Sources/7-Zip/7zFolder.swift @@ -190,7 +190,7 @@ class SevenZipFolder { try decoder.decode() decodedData = Data(bytes: decoder.out) default: - if coder.id[0] == 0x06 { + if coder.isEncryptionMethod { throw SevenZipError.encryptionNotSupported } else { throw SevenZipError.compressionNotSupported