mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
Swiftlint autocorect
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import Foundation
|
||||
|
||||
public extension BZip2 {
|
||||
|
||||
|
||||
public enum BlockSize: Int {
|
||||
case one = 1
|
||||
case two = 2
|
||||
@@ -21,7 +21,7 @@ public extension BZip2 {
|
||||
}
|
||||
|
||||
extension BZip2.BlockSize {
|
||||
|
||||
|
||||
func headerByte() -> Int {
|
||||
switch self {
|
||||
case .one:
|
||||
@@ -44,5 +44,5 @@ extension BZip2.BlockSize {
|
||||
return 0x39
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
import Foundation
|
||||
|
||||
extension BZip2: CompressionAlgorithm {
|
||||
|
||||
|
||||
public static func compress(data: Data) -> Data {
|
||||
return compress(data: data, blockSize: .one)
|
||||
}
|
||||
|
||||
|
||||
public static func compress(data: Data, blockSize: BlockSize) -> Data {
|
||||
let bitWriter = BitWriter(bitOrder: .straight)
|
||||
let rawBlockSize = blockSize.rawValue * 100 * 1024
|
||||
@@ -23,10 +23,10 @@ extension BZip2: CompressionAlgorithm {
|
||||
for i in stride(from: 0, to: data.count, by: rawBlockSize) {
|
||||
let blockData = data.subdata(in: i..<min(data.count, i + rawBlockSize))
|
||||
let blockCRC = CheckSums.bzip2CRC32(blockData)
|
||||
|
||||
|
||||
totalCRC = (totalCRC << 1) | (totalCRC >> 31)
|
||||
totalCRC ^= blockCRC
|
||||
|
||||
|
||||
// Start block header.
|
||||
bitWriter.write(number: 0x314159265359, bitsCount: 48) // Block magic number.
|
||||
bitWriter.write(number: blockCRC.toInt(), bitsCount: 32) // Block crc32.
|
||||
@@ -45,7 +45,7 @@ extension BZip2: CompressionAlgorithm {
|
||||
|
||||
private static func process(block data: Data, _ bitWriter: BitWriter) {
|
||||
var out = [Int]()
|
||||
|
||||
|
||||
// Run Length Encoding
|
||||
var index = 0
|
||||
while index < data.count {
|
||||
@@ -322,4 +322,3 @@ extension BZip2: CompressionAlgorithm {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -60,5 +60,4 @@ class BurrowsWheeler {
|
||||
return pointers
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ public protocol DecompressionAlgorithm {
|
||||
|
||||
/// A type that provides an implementation of a particular compression algorithm.
|
||||
public protocol CompressionAlgorithm {
|
||||
|
||||
|
||||
/// Cmpress data with particular algorithm.
|
||||
static func compress(data: Data) throws -> Data
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// A type that represents a container of files, directories and/or other data.
|
||||
|
||||
@@ -7,7 +7,7 @@ import Foundation
|
||||
|
||||
/// Provides unarchive function for XZ archives.
|
||||
public class XZArchive: Archive {
|
||||
|
||||
|
||||
enum CheckType: Int {
|
||||
case none = 0x00
|
||||
case crc32 = 0x01
|
||||
|
||||
@@ -93,7 +93,7 @@ class BZip2CompressTests: XCTestCase {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
func testWithAnswer8BZip2Compress() throws {
|
||||
try answerTest("test8")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user