Fixed typo in the name of the function. Added function to get bytes.

This commit is contained in:
Timofey Solomko
2016-12-18 16:23:37 +03:00
parent ebd50d61fe
commit fb45daaf67
4 changed files with 15 additions and 5 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
// SWCompression
//
// Created by Timofey Solomko on 18.12.16.
// Copyright © 2016 tsolomko. All rights reserved.
// Copyright © 2016 Timofey Solomko. All rights reserved.
//
import Foundation
+11 -1
View File
@@ -126,7 +126,17 @@ class DataWithPointer {
return self.bitArray[self.index - 1]
}
func intFromAlingedBytes(count: Int) -> Int {
func alignedBytes(count: Int) -> [UInt8] {
self.skipUntilNextByte()
var result: [UInt8] = Array(repeating: 0, count: count)
for i in 0..<count {
result[i] = self.bitArray[self.index]
self.index += 1
}
return result
}
func intFromAlignedBytes(count: Int) -> Int {
self.skipUntilNextByte()
var result = 0
for i in 0..<count {
+2 -2
View File
@@ -328,13 +328,13 @@ public final class LZMA: DecompressionAlgorithm {
let pb = properties / 5
/// The number of literal pos bits
let lp = properties % 5
var dictionarySize = pointerData.intFromAlingedBytes(count: 4)
var dictionarySize = pointerData.intFromAlignedBytes(count: 4)
dictionarySize = dictionarySize < (1 << 12) ? 1 << 12 : dictionarySize
lzmaInfoPrint("lc: \(lc), lp: \(lp), pb: \(pb), dictionarySize: \(dictionarySize)")
/// Size of uncompressed data. -1 means it is unknown.
var uncompressedSize = pointerData.intFromAlingedBytes(count: 8)
var uncompressedSize = pointerData.intFromAlignedBytes(count: 8)
uncompressedSize = Double(uncompressedSize) == pow(Double(2), Double(64)) - 1 ? -1 : uncompressedSize
/// An array for storing output data