From dffceccb846e94237ebb0e600af237c371af54dd Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Tue, 9 May 2017 21:07:50 +0300 Subject: [PATCH] Fixed a mistake with length of fileComment. --- Sources/ZipContainer.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Sources/ZipContainer.swift b/Sources/ZipContainer.swift index 5297fc0c..48666f93 100644 --- a/Sources/ZipContainer.swift +++ b/Sources/ZipContainer.swift @@ -58,7 +58,7 @@ public class ZipEntry: ContainerEntry { private var pointerData: DataWithPointer /// Name of the file or directory. - public var name: String? { + public var name: String { return self.cdEntry.fileName } @@ -72,6 +72,14 @@ public class ZipEntry: ContainerEntry { return self.cdEntry.externalFileAttributes } + public var size: Int { + return Int(truncatingBitPattern: cdEntry.uncompSize) + } + + public var isDirectory: Bool { + return false // TODO: Implement. + } + /** Returns data associated with this entry. @@ -396,7 +404,7 @@ struct CentralDirectoryEntry { } } - guard let fileComment = String(data: Data(bytes: pointerData.alignedBytes(count: fileNameLength)), + guard let fileComment = String(data: Data(bytes: pointerData.alignedBytes(count: fileCommentLength)), encoding: .utf8) else { throw ZipError.wrongTextField } self.fileComment = fileComment