summaryrefslogtreecommitdiff
path: root/Sora/Data/JSONFileDocument.swift
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-03-03 03:08:52 -0800
committerFuwn <[email protected]>2025-03-03 03:08:52 -0800
commit2646279dc1378d0c63e91372486baa85d83590bd (patch)
tree740abe2babf8e4ca9d9c4b86f64f2e4301533a98 /Sora/Data/JSONFileDocument.swift
parentfeat: Development commit (diff)
downloadsora-testing-2646279dc1378d0c63e91372486baa85d83590bd.tar.xz
sora-testing-2646279dc1378d0c63e91372486baa85d83590bd.zip
feat: Development commit
Diffstat (limited to 'Sora/Data/JSONFileDocument.swift')
-rw-r--r--Sora/Data/JSONFileDocument.swift26
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)
+ }
+}