DataCompression
DataCompression copied to clipboard
Property if data is compressed
Is there a way to check if a given set of data is compressed in any way? like data.isGzipped -> true or data.compression -> Compression.gzip || Compression.zip ,....
If not this would be a feature request
Yes that seems plausible. Will try to get this into the next release. Just some notes: This will not be possible for all compression methods. Probably only gzip and zip, because the other steams don't have an identifying header.
extension Data {
public var isGzipped :Bool {
return self.starts(with: [0x1f,0x8b])
}
}
You can use this code to check data is compressed with gzip