From 6b8c90f0bdc79fdc33ebf697cf76f7f462b987db Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Sat, 11 Nov 2017 11:46:22 +0300 Subject: [PATCH] FileSystemType properties can no longer be nil --- Sources/GZip/FileSystemType+Gzip.swift | 6 ++---- Sources/GZip/GzipHeader.swift | 3 +-- Sources/ZIP/FileSystemType+Zip.swift | 6 ++---- Sources/ZIP/ZipEntryInfo.swift | 2 +- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Sources/GZip/FileSystemType+Gzip.swift b/Sources/GZip/FileSystemType+Gzip.swift index 4a9ec0b0..98bde995 100644 --- a/Sources/GZip/FileSystemType+Gzip.swift +++ b/Sources/GZip/FileSystemType+Gzip.swift @@ -7,7 +7,7 @@ import Foundation extension FileSystemType { - init?(_ gzipOS: UInt8) { + init(_ gzipOS: UInt8) { switch gzipOS { case 0: self = .fat @@ -17,10 +17,8 @@ extension FileSystemType { self = .macintosh case 11: self = .ntfs - case 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 255: - self = .other default: - return nil + self = .other } } diff --git a/Sources/GZip/GzipHeader.swift b/Sources/GZip/GzipHeader.swift index 186ee1bd..e50bf9e6 100644 --- a/Sources/GZip/GzipHeader.swift +++ b/Sources/GZip/GzipHeader.swift @@ -32,9 +32,8 @@ public struct GzipHeader { */ public let modificationTime: Date? - // TODO: Explain why can be nil? /// Type of file system on which archivation took place. - public let osType: FileSystemType? + public let osType: FileSystemType /// Name of the original file. If archive doesn't contain file's name, then `nil`. public let fileName: String? diff --git a/Sources/ZIP/FileSystemType+Zip.swift b/Sources/ZIP/FileSystemType+Zip.swift index 6f70e029..0d0ffab0 100644 --- a/Sources/ZIP/FileSystemType+Zip.swift +++ b/Sources/ZIP/FileSystemType+Zip.swift @@ -7,7 +7,7 @@ import Foundation extension FileSystemType { - init?(_ versionMadeBy: UInt16) { + init(_ versionMadeBy: UInt16) { switch (versionMadeBy & 0xFF00) >> 8 { case 0, 14: self = .fat @@ -17,10 +17,8 @@ extension FileSystemType { self = .macintosh case 10: self = .ntfs - case 1, 2, 4, 5, 6, 8, 9, 11, 12, 13, 15, 16, 17, 18: - self = .other default: - return nil + self = .other } } diff --git a/Sources/ZIP/ZipEntryInfo.swift b/Sources/ZIP/ZipEntryInfo.swift index 26554d59..078a9e49 100644 --- a/Sources/ZIP/ZipEntryInfo.swift +++ b/Sources/ZIP/ZipEntryInfo.swift @@ -37,7 +37,7 @@ public struct ZipEntryInfo: ContainerEntryInfo { /// True, if entry is likely to be text or ASCII file. public let isTextFile: Bool - public let fileSystemType: FileSystemType? + public let fileSystemType: FileSystemType public let compressionMethod: CompressionMethod