Skip to content

Commit

Permalink
Add public isCompressed property
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomasser committed Oct 7, 2022
1 parent 7f99ebd commit 63bdd47
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sources/ZIPFoundation/Entry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ public struct Entry: Equatable {
default: return isDirectory ? .directory : .file
}
}
/// Whether or not the receiver is compressed.
public var isCompressed: Bool {
self.localFileHeader.compressionMethod != CompressionMethod.none.rawValue
}
/// The size of the receiver's compressed data.
public var compressedSize: UInt64 {
if centralDirectoryStructure.isZIP64 {
Expand All @@ -186,8 +190,7 @@ public struct Entry: Equatable {
var extraDataLength = Int(localFileHeader.fileNameLength)
extraDataLength += Int(localFileHeader.extraFieldLength)
var size = UInt64(LocalFileHeader.size + extraDataLength)
let isCompressed = localFileHeader.compressionMethod != CompressionMethod.none.rawValue
size += isCompressed ? self.compressedSize : self.uncompressedSize
size += self.isCompressed ? self.compressedSize : self.uncompressedSize
if centralDirectoryStructure.isZIP64 {
size += self.zip64DataDescriptor != nil ? UInt64(ZIP64DataDescriptor.size) : 0
} else {
Expand Down

0 comments on commit 63bdd47

Please sign in to comment.