mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
23 lines
587 B
Swift
23 lines
587 B
Swift
import SwiftUI
|
|
import UniformTypeIdentifiers
|
|
|
|
struct LogDocument: FileDocument {
|
|
static var readableContentTypes: [UTType] {[.plainText]}
|
|
|
|
var logFile: String
|
|
|
|
init(logFile: String) {
|
|
self.logFile = logFile
|
|
}
|
|
|
|
init(configuration: ReadConfiguration) throws {
|
|
guard let data = configuration.file.regularFileContents else {
|
|
throw CocoaError(.fileReadCorruptFile)
|
|
}
|
|
logFile = String(decoding: data, as: UTF8.self)
|
|
}
|
|
|
|
func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
|
|
return FileWrapper(regularFileWithContents: logFile.data(using: .utf8)!)
|
|
}
|
|
}
|