diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2024-07-28 00:02:07 -0600 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2024-07-28 00:02:07 -0600 |
commit | dfbc19e5e78d87ec735839333a647cae409f53eb (patch) | |
tree | 9849417658ccdc71be35a5be5e687caedb60d535 /Sources/GopherHelpers/GopherHelpers.swift | |
parent | 35f2f975fd0ff66f87bca546dcd12fdd6fc5869f (diff) |
swift-format
Diffstat (limited to 'Sources/GopherHelpers/GopherHelpers.swift')
-rw-r--r-- | Sources/GopherHelpers/GopherHelpers.swift | 390 |
1 files changed, 195 insertions, 195 deletions
diff --git a/Sources/GopherHelpers/GopherHelpers.swift b/Sources/GopherHelpers/GopherHelpers.swift index 15f14cb..d561d33 100644 --- a/Sources/GopherHelpers/GopherHelpers.swift +++ b/Sources/GopherHelpers/GopherHelpers.swift @@ -43,216 +43,216 @@ import NIOCore */ public enum gopherItemType { - case text - case directory - case nameserver - case error - case binhex - case bindos - case uuencoded - case search - case telnet - case binary - case mirror - case gif - case image - case tn3270Session - case bitmap - case movie - case sound - case doc - case html - case info + case text + case directory + case nameserver + case error + case binhex + case bindos + case uuencoded + case search + case telnet + case binary + case mirror + case gif + case image + case tn3270Session + case bitmap + case movie + case sound + case doc + case html + case info } public struct gopherItem { - public var rawLine: String - public var rawData: ByteBuffer? - public var message: String = "" - public var parsedItemType: gopherItemType = .info - public var host: String = "error.host" - public var port: Int = 1 - public var selector: String = "" - public var valid: Bool = true + public var rawLine: String + public var rawData: ByteBuffer? + public var message: String = "" + public var parsedItemType: gopherItemType = .info + public var host: String = "error.host" + public var port: Int = 1 + public var selector: String = "" + public var valid: Bool = true - public init(rawLine: String) { - self.rawLine = rawLine - } + public init(rawLine: String) { + self.rawLine = rawLine + } } public func getGopherFileType(item: String) -> gopherItemType { - switch item { - case "0": - return .text - case "1": - return .directory - case "2": - return .nameserver - case "3": - return .error - case "4": - return .binhex - case "5": - return .bindos - case "6": - return .uuencoded - case "7": - return .search - case "8": - return .telnet - case "9": - return .binary - case "+": - return .mirror - case "g": - return .gif - case "I": - return .image - case "T": - return .tn3270Session - case ":": - return .bitmap - case ";": - return .movie - case "<": - return .sound - case "d": - return .doc - case "h": - return .html - case "i": - return .info - case "p": - return .image - case "r": - return .doc - case "s": - return .doc - case "P": - return .doc - case "X": - return .doc - default: - return .info - } + switch item { + case "0": + return .text + case "1": + return .directory + case "2": + return .nameserver + case "3": + return .error + case "4": + return .binhex + case "5": + return .bindos + case "6": + return .uuencoded + case "7": + return .search + case "8": + return .telnet + case "9": + return .binary + case "+": + return .mirror + case "g": + return .gif + case "I": + return .image + case "T": + return .tn3270Session + case ":": + return .bitmap + case ";": + return .movie + case "<": + return .sound + case "d": + return .doc + case "h": + return .html + case "i": + return .info + case "p": + return .image + case "r": + return .doc + case "s": + return .doc + case "P": + return .doc + case "X": + return .doc + default: + return .info + } } public func getFileType(fileExtension: String) -> gopherItemType { - switch fileExtension { - case "txt": - return .text - case "md": - return .text - case "html": - return .html - case "pdf": - return .doc - case "png": - return .image - case "gif": - return .gif - case "jpg": - return .image - case "jpeg": - return .image - case "mp3": - return .sound - case "wav": - return .sound - case "mp4": - return .movie - case "mov": - return .movie - case "avi": - return .movie - case "rtf": - return .doc - case "xml": - return .doc - default: - return .binary - } + switch fileExtension { + case "txt": + return .text + case "md": + return .text + case "html": + return .html + case "pdf": + return .doc + case "png": + return .image + case "gif": + return .gif + case "jpg": + return .image + case "jpeg": + return .image + case "mp3": + return .sound + case "wav": + return .sound + case "mp4": + return .movie + case "mov": + return .movie + case "avi": + return .movie + case "rtf": + return .doc + case "xml": + return .doc + default: + return .binary + } } public func fileTypeToGopherItem(fileType: gopherItemType) -> String { - switch fileType { - case .text: - return "0" - case .directory: - return "1" - case .nameserver: - return "2" - case .error: - return "3" - case .binhex: - return "4" - case .bindos: - return "5" - case .uuencoded: - return "6" - case .search: - return "7" - case .telnet: - return "8" - case .binary: - return "9" - case .mirror: - return "+" - case .tn3270Session: - return "T" - case .gif: - return "g" - case .image: - return "I" - case .bitmap: - return "b" - case .movie: - return "M" - case .sound: - return "s" - case .doc: - return "d" - case .html: - return "h" - case .info: - return "i" - // case .png: - // return "p" - // case .rtf: - // return "t" - // case .wavfile: - // return "w" - // case .pdf: - // return "P" - // case .xml: - // return "x" - } + switch fileType { + case .text: + return "0" + case .directory: + return "1" + case .nameserver: + return "2" + case .error: + return "3" + case .binhex: + return "4" + case .bindos: + return "5" + case .uuencoded: + return "6" + case .search: + return "7" + case .telnet: + return "8" + case .binary: + return "9" + case .mirror: + return "+" + case .tn3270Session: + return "T" + case .gif: + return "g" + case .image: + return "I" + case .bitmap: + return "b" + case .movie: + return "M" + case .sound: + return "s" + case .doc: + return "d" + case .html: + return "h" + case .info: + return "i" + // case .png: + // return "p" + // case .rtf: + // return "t" + // case .wavfile: + // return "w" + // case .pdf: + // return "P" + // case .xml: + // return "x" + } } public func itemToImageType(_ item: gopherItem) -> String { - switch item.parsedItemType { - case .text: - return "doc.plaintext" - case .directory: - return "folder" - case .error: - return "exclamationmark.triangle" - case .gif: - return "photo.stack" - case .image: - return "photo" - case .doc: - return "doc.richtext" - case .sound: - return "music.note" - case .bitmap: - return "photo" - case .html: - return "globe" - case .movie: - return "videoprojector" - default: - return "questionmark.square.dashed" - } + switch item.parsedItemType { + case .text: + return "doc.plaintext" + case .directory: + return "folder" + case .error: + return "exclamationmark.triangle" + case .gif: + return "photo.stack" + case .image: + return "photo" + case .doc: + return "doc.richtext" + case .sound: + return "music.note" + case .bitmap: + return "photo" + case .html: + return "globe" + case .movie: + return "videoprojector" + default: + return "questionmark.square.dashed" + } } |