diff --git a/Sources/7-Zip/7zContainer.swift b/Sources/7-Zip/7zContainer.swift index ac8f4380..a87b1cf8 100644 --- a/Sources/7-Zip/7zContainer.swift +++ b/Sources/7-Zip/7zContainer.swift @@ -232,8 +232,8 @@ public class SevenZipContainer: Container { let startHeaderCRC = bitReader.uint32() /// - Note: Relative to SignatureHeader - let nextHeaderOffset = Int(bitReader.uint64()) - let nextHeaderSize = Int(bitReader.uint64()) + let nextHeaderOffset = bitReader.uint64().toInt() + let nextHeaderSize = bitReader.uint64().toInt() let nextHeaderCRC = bitReader.uint32() bitReader.offset = 12 diff --git a/Sources/Deflate/Deflate+Compress.swift b/Sources/Deflate/Deflate+Compress.swift index d2b34830..52e3b110 100644 --- a/Sources/Deflate/Deflate+Compress.swift +++ b/Sources/Deflate/Deflate+Compress.swift @@ -119,15 +119,15 @@ extension Deflate: CompressionAlgorithm { case let .byte(byte): mainLiterals.code(symbol: byte.toInt()) case let .lengthDistance(length, distance): - let lengthSymbol = Constants.lengthCode[Int(length) - 3] - let lengthExtraBits = Int(length) - Constants.lengthBase[lengthSymbol - 257] + let lengthSymbol = Constants.lengthCode[length.toInt() - 3] + let lengthExtraBits = length.toInt() - Constants.lengthBase[lengthSymbol - 257] let lengthExtraBitsCount = (257 <= lengthSymbol && lengthSymbol <= 260) || lengthSymbol == 285 ? 0 : (((lengthSymbol - 257) >> 2) - 1) mainLiterals.code(symbol: lengthSymbol) bitWriter.write(number: lengthExtraBits, bitsCount: lengthExtraBitsCount) - let distanceSymbol = ((Constants.distanceBase.index { $0 > Int(distance) }) ?? 30) - 1 - let distanceExtraBits = Int(distance) - Constants.distanceBase[distanceSymbol] + let distanceSymbol = ((Constants.distanceBase.index { $0 > distance.toInt() }) ?? 30) - 1 + let distanceExtraBits = distance.toInt() - Constants.distanceBase[distanceSymbol] let distanceExtraBitsCount = distanceSymbol == 0 || distanceSymbol == 1 ? 0 : ((distanceSymbol >> 1) - 1) mainDistances.code(symbol: distanceSymbol) diff --git a/Sources/LZMA/LZMA.swift b/Sources/LZMA/LZMA.swift index a60c8bc3..2615776f 100644 --- a/Sources/LZMA/LZMA.swift +++ b/Sources/LZMA/LZMA.swift @@ -36,7 +36,7 @@ public class LZMA: DecompressionAlgorithm { if uncompSize == UInt64.max { decoder.uncompressedSize = -1 } else { - decoder.uncompressedSize = Int(truncatingIfNeeded: uncompSize) + decoder.uncompressedSize = uncompSize.toInt() } try decoder.decode() diff --git a/Sources/LZMA/LZMARangeDecoder.swift b/Sources/LZMA/LZMARangeDecoder.swift index 378f0919..9636aafe 100644 --- a/Sources/LZMA/LZMARangeDecoder.swift +++ b/Sources/LZMA/LZMARangeDecoder.swift @@ -65,7 +65,7 @@ class LZMARangeDecoder { res = res &+ (t &+ 1) count -= 1 } while count > 0 - return Int(res) + return res.toInt() } /// Decodes binary symbol (bit) with predicted (estimated) probability. diff --git a/Sources/LZMA2/LZMA2Decoder.swift b/Sources/LZMA2/LZMA2Decoder.swift index 982a7da2..666fc9f6 100644 --- a/Sources/LZMA2/LZMA2Decoder.swift +++ b/Sources/LZMA2/LZMA2Decoder.swift @@ -35,7 +35,7 @@ class LZMA2Decoder { dictSize <<= UInt32(bits.toInt() / 2 + 11) } - self.decoder.dictionarySize = Int(dictSize) + self.decoder.dictionarySize = dictSize.toInt() } /// Main LZMA2 decoder function. diff --git a/Sources/ZIP/ZipContainer.swift b/Sources/ZIP/ZipContainer.swift index 1169a9f2..de247b52 100644 --- a/Sources/ZIP/ZipContainer.swift +++ b/Sources/ZIP/ZipContainer.swift @@ -55,7 +55,7 @@ public class ZipContainer: Container { byteReader.offset = info.localHeader.dataOffset switch info.compressionMethod { case .copy: - fileData = Data(bytes: byteReader.bytes(count: Int(truncatingIfNeeded: uncompSize))) + fileData = Data(bytes: byteReader.bytes(count: uncompSize.toInt())) case .deflate: let bitReader = LsbBitReader(data: byteReader.data) bitReader.offset = byteReader.offset @@ -149,12 +149,12 @@ public class ZipContainer: Container { let cdEntries = endOfCD.cdEntries // OK, now we are ready to read Central Directory itself. - var entryIndex = Int(truncatingIfNeeded: endOfCD.cdOffset) + var entryIndex = endOfCD.cdOffset.toInt() // First, check for "Archive extra data record" and skip it if present. byteReader.offset = entryIndex if byteReader.uint32() == 0x08064b50 { - entryIndex += Int(truncatingIfNeeded: byteReader.uint32()) + entryIndex += byteReader.uint32().toInt() } for _ in 0..