GTK now opens each document into a fresh working copy and exports a VACUUM INTO snapshot to the user-facing path on save and on close. Hooks stay attached across Save As since the engine never moves. The window close handler holds the GApplication while the snapshot and shutdown drain. Engine.shutdown flushes EventLog and awaits the chained event-store writes so events.log is durable. LumaProject and ProjectAutosaver share the snapshot helper.
61 lines
2.5 KiB
Swift
61 lines
2.5 KiB
Swift
import Foundation
|
|
|
|
public struct LumaAppPaths: Sendable {
|
|
public let stateURL: URL
|
|
public let untitledDirectory: URL
|
|
public let dataDirectory: URL
|
|
|
|
public var workingDirectory: URL {
|
|
untitledDirectory.appendingPathComponent(".working", isDirectory: true)
|
|
}
|
|
|
|
public init(stateURL: URL, untitledDirectory: URL, dataDirectory: URL) {
|
|
self.stateURL = stateURL
|
|
self.untitledDirectory = untitledDirectory
|
|
self.dataDirectory = dataDirectory
|
|
}
|
|
|
|
public static let shared: LumaAppPaths = makeDefault()
|
|
|
|
private static func makeDefault() -> LumaAppPaths {
|
|
let fm = FileManager.default
|
|
#if os(macOS) || os(iOS) || os(visionOS)
|
|
let appSupport = try! fm.url(
|
|
for: .applicationSupportDirectory,
|
|
in: .userDomainMask,
|
|
appropriateFor: nil,
|
|
create: true
|
|
)
|
|
let bundleID = Bundle.main.bundleIdentifier ?? "re.frida.Luma"
|
|
let root = appSupport.appendingPathComponent(bundleID, isDirectory: true)
|
|
try? fm.createDirectory(at: root, withIntermediateDirectories: true)
|
|
let untitled = root.appendingPathComponent("Untitled", isDirectory: true)
|
|
try? fm.createDirectory(at: untitled, withIntermediateDirectories: true)
|
|
return LumaAppPaths(
|
|
stateURL: root.appendingPathComponent("state.json"),
|
|
untitledDirectory: untitled,
|
|
dataDirectory: root
|
|
)
|
|
#else
|
|
let env = ProcessInfo.processInfo.environment
|
|
let xdgConfigHome = env["XDG_CONFIG_HOME"]
|
|
.map(URL.init(fileURLWithPath:))
|
|
?? URL(fileURLWithPath: NSHomeDirectory()).appendingPathComponent(".config")
|
|
let xdgDataHome = env["XDG_DATA_HOME"]
|
|
.map(URL.init(fileURLWithPath:))
|
|
?? URL(fileURLWithPath: NSHomeDirectory()).appendingPathComponent(".local/share")
|
|
let configDir = xdgConfigHome.appendingPathComponent("luma", isDirectory: true)
|
|
try? fm.createDirectory(at: configDir, withIntermediateDirectories: true)
|
|
let dataDir = xdgDataHome.appendingPathComponent("luma", isDirectory: true)
|
|
try? fm.createDirectory(at: dataDir, withIntermediateDirectories: true)
|
|
let untitled = dataDir.appendingPathComponent("Untitled", isDirectory: true)
|
|
try? fm.createDirectory(at: untitled, withIntermediateDirectories: true)
|
|
return LumaAppPaths(
|
|
stateURL: configDir.appendingPathComponent("state.json"),
|
|
untitledDirectory: untitled,
|
|
dataDirectory: dataDir
|
|
)
|
|
#endif
|
|
}
|
|
}
|