diff --git a/Sources/7-Zip/7zContainer.swift b/Sources/7-Zip/7zContainer.swift index df2d304f..632f4231 100644 --- a/Sources/7-Zip/7zContainer.swift +++ b/Sources/7-Zip/7zContainer.swift @@ -97,7 +97,7 @@ public class SevenZipContainer: Container { } // Load the stream. - let streamData = Data(bytes: byteReader.bytes(count: packInfo.packSizes[streamIndex])) + let streamData = Data(byteReader.bytes(count: packInfo.packSizes[streamIndex])) // Check stream's CRC, if it's available. if streamIndex < packInfo.digests.count, @@ -122,7 +122,7 @@ public class SevenZipContainer: Container { // Check, if we aren't about to read too much from a stream. guard fileSize <= unpackedStreamData.bytesLeft else { throw SevenZipError.internalStructureError } - let fileData = Data(bytes: unpackedStreamData.bytes(count: fileSize)) + let fileData = Data(unpackedStreamData.bytes(count: fileSize)) let calculatedFileCRC = CheckSums.crc32(fileData) if nonEmptyFileIndex < substreamInfo.digests.count { diff --git a/Sources/BZip2/BZip2.swift b/Sources/BZip2/BZip2.swift index f48a1148..c84e658a 100644 --- a/Sources/BZip2/BZip2.swift +++ b/Sources/BZip2/BZip2.swift @@ -218,7 +218,7 @@ public class BZip2: DecompressionAlgorithm { } } - return Data(bytes: out) + return Data(out) } } diff --git a/Sources/Common/DeltaFilter.swift b/Sources/Common/DeltaFilter.swift index 5dc5e1cc..8f05ddba 100644 --- a/Sources/Common/DeltaFilter.swift +++ b/Sources/Common/DeltaFilter.swift @@ -29,7 +29,7 @@ final class DeltaFilter { } } - return Data(bytes: out) + return Data(out) } } diff --git a/Sources/Deflate/Deflate.swift b/Sources/Deflate/Deflate.swift index 0df8a454..19c6f26c 100644 --- a/Sources/Deflate/Deflate.swift +++ b/Sources/Deflate/Deflate.swift @@ -203,7 +203,7 @@ public class Deflate: DecompressionAlgorithm { } } - return Data(bytes: out) + return Data(out) } } diff --git a/Sources/GZip/GzipArchive.swift b/Sources/GZip/GzipArchive.swift index 9b58d381..bee4cc20 100644 --- a/Sources/GZip/GzipArchive.swift +++ b/Sources/GZip/GzipArchive.swift @@ -170,7 +170,7 @@ public class GzipArchive: Archive { headerBytes.append(2) // Extra flags; 2 means that DEFLATE used slowest algorithm. headerBytes.append(os) - var outData = Data(bytes: headerBytes) + var outData = Data(headerBytes) outData.append(fileNameData) outData.append(commentData) @@ -189,14 +189,14 @@ public class GzipArchive: Archive { for i: UInt32 in 0..<4 { crcBytes.append(UInt8(truncatingIfNeeded: (crc32 & (0xFF << (i * 8))) >> (i * 8))) } - outData.append(Data(bytes: crcBytes)) + outData.append(Data(crcBytes)) let isize = UInt64(data.count) % UInt64(1) << 32 var isizeBytes = [UInt8]() for i: UInt64 in 0..<4 { isizeBytes.append(UInt8(truncatingIfNeeded: (isize & (0xFF << (i * 8))) >> (i * 8))) } - outData.append(Data(bytes: isizeBytes)) + outData.append(Data(isizeBytes)) return outData } diff --git a/Sources/LZMA/LZMA.swift b/Sources/LZMA/LZMA.swift index 039ec105..3d4e39b9 100644 --- a/Sources/LZMA/LZMA.swift +++ b/Sources/LZMA/LZMA.swift @@ -65,7 +65,7 @@ public class LZMA: DecompressionAlgorithm { decoder.uncompressedSize = uncompSize ?? -1 try decoder.decode() - return Data(bytes: decoder.out) + return Data(decoder.out) } } diff --git a/Sources/LZMA2/LZMA2.swift b/Sources/LZMA2/LZMA2.swift index 535bd501..dad7de02 100644 --- a/Sources/LZMA2/LZMA2.swift +++ b/Sources/LZMA2/LZMA2.swift @@ -30,7 +30,7 @@ public class LZMA2: DecompressionAlgorithm { static func decompress(_ byteReader: ByteReader, _ dictSizeByte: UInt8) throws -> Data { let decoder = try LZMA2Decoder(byteReader, dictSizeByte) try decoder.decode() - return Data(bytes: decoder.out) + return Data(decoder.out) } } diff --git a/Sources/TAR/TarEntryInfo.swift b/Sources/TAR/TarEntryInfo.swift index b26d5dfc..b59be802 100644 --- a/Sources/TAR/TarEntryInfo.swift +++ b/Sources/TAR/TarEntryInfo.swift @@ -406,7 +406,7 @@ public struct TarEntryInfo: ContainerEntryInfo { // It determines the end of the actual prefix and the beginning of the updated name field. #if (swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))) || !os(Linux) let lastPrefixSlashIndex = nameData.prefix(upTo: maxPrefixLength) - .range(of: Data(bytes: [0x2f]), options: .backwards)?.lowerBound ?? -1 + .range(of: Data([0x2f]), options: .backwards)?.lowerBound ?? -1 #else // TODO: This is a workaround for runtime crash in `Data.prefix(upTo:).range(of:options:)` on Linux with // Swift 4.1. It seems like it is fixed in 4.2 and master snapshots, so it will be removed when Swift @@ -480,7 +480,7 @@ fileprivate extension Data { value >>= 8 } buffer[0] |= 0x80 // Highest bit indicates base-256 encoding. - self.append(Data(bytes: buffer)) + self.append(Data(buffer)) } mutating func append(tarString string: String?, maxLength: Int) throws { diff --git a/Sources/ZIP/ZipContainer.swift b/Sources/ZIP/ZipContainer.swift index 1c8903e9..5f4df6b2 100644 --- a/Sources/ZIP/ZipContainer.swift +++ b/Sources/ZIP/ZipContainer.swift @@ -66,7 +66,7 @@ public class ZipContainer: Container { byteReader.offset = helper.dataOffset switch helper.entryInfo.compressionMethod { case .copy: - fileData = Data(bytes: byteReader.bytes(count: uncompSize.toInt())) + fileData = Data(byteReader.bytes(count: uncompSize.toInt())) case .deflate: let bitReader = LsbBitReader(byteReader) fileData = try Deflate.decompress(bitReader) diff --git a/Sources/ZIP/ZipEndOfCentralDirectory.swift b/Sources/ZIP/ZipEndOfCentralDirectory.swift index ee2c95da..4c10798f 100644 --- a/Sources/ZIP/ZipEndOfCentralDirectory.swift +++ b/Sources/ZIP/ZipEndOfCentralDirectory.swift @@ -41,7 +41,7 @@ struct ZipEndOfCentralDirectory { // There is also a .ZIP file comment, but we don't need it. // Here's how it can be processed: // let zipCommentLength = byteReader.int(fromBytes: 2) - // let zipComment = String(data: Data(bytes: byteReader.bytes(count: zipCommentLength)), + // let zipComment = String(data: Data(byteReader.bytes(count: zipCommentLength)), // encoding: .utf8) // Check if zip64 records are present. diff --git a/Sources/Zlib/ZlibArchive.swift b/Sources/Zlib/ZlibArchive.swift index b5a7cb33..5d50fd1b 100644 --- a/Sources/Zlib/ZlibArchive.swift +++ b/Sources/Zlib/ZlibArchive.swift @@ -53,7 +53,7 @@ public class ZlibArchive: Archive { 120, // CM (Compression Method) = 8 (DEFLATE), CINFO (Compression Info) = 7 (32K window size). 218 // Flags: slowest algorithm, no preset dictionary. ] - var outData = Data(bytes: out) + var outData = Data(out) outData.append(Deflate.compress(data: data)) let adler32 = CheckSums.adler32(data) @@ -61,7 +61,7 @@ public class ZlibArchive: Archive { for i in 0..<4 { adlerBytes.append(UInt8(truncatingIfNeeded: (adler32 & (0xFF << ((3 - i) * 8))) >> ((3 - i) * 8))) } - outData.append(Data(bytes: adlerBytes)) + outData.append(Data(adlerBytes)) return outData } diff --git a/Tests/TestZipExtraField.swift b/Tests/TestZipExtraField.swift index a8812986..ee0e62be 100644 --- a/Tests/TestZipExtraField.swift +++ b/Tests/TestZipExtraField.swift @@ -19,7 +19,7 @@ struct TestZipExtraField: ZipExtraField { init(_ byteReader: ByteReader, _ size: Int, location: ZipExtraFieldLocation) { self.size = size self.location = location - self.helloString = String(data: Data(bytes: byteReader.bytes(count: size)), encoding: .utf8) + self.helloString = String(data: Data(byteReader.bytes(count: size)), encoding: .utf8) } }