diff options
| author | Fuwn <[email protected]> | 2025-03-03 03:08:52 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-03-03 03:08:52 -0800 |
| commit | 2646279dc1378d0c63e91372486baa85d83590bd (patch) | |
| tree | 740abe2babf8e4ca9d9c4b86f64f2e4301533a98 /Sora/Data/JSONFileDocument.swift | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-2646279dc1378d0c63e91372486baa85d83590bd.tar.xz sora-testing-2646279dc1378d0c63e91372486baa85d83590bd.zip | |
feat: Development commit
Diffstat (limited to 'Sora/Data/JSONFileDocument.swift')
| -rw-r--r-- | Sora/Data/JSONFileDocument.swift | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Sora/Data/JSONFileDocument.swift b/Sora/Data/JSONFileDocument.swift new file mode 100644 index 0000000..bc41616 --- /dev/null +++ b/Sora/Data/JSONFileDocument.swift @@ -0,0 +1,26 @@ +import SwiftUI +import UniformTypeIdentifiers + +struct JSONFileDocument: FileDocument { + static var readableContentTypes: [UTType] { [.json] } + + var data: Data + + init(_ data: Data) throws { + self.data = data + } + + init(configuration: ReadConfiguration) throws { + guard let data = configuration.file.regularFileContents else { + throw CocoaError(.fileReadCorruptFile) + } + + self.data = data + } + + func fileWrapper( + configuration: WriteConfiguration // swiftlint:disable:this unused_parameter + ) throws -> FileWrapper { + FileWrapper(regularFileWithContents: data) + } +} |