Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536#if DEBUG && PARCEL_REALITY import AppKit import Foundation
struct AppRelaunchReceipt: Codable { let parent: Int32 let helper: Int32 let bundlePath: String var replacement: Int32? var launchDate: Date?
static var url: URL? { let environment = ProcessInfo.processInfo.environment guard environment["PARCEL_REALITY"] == "1", let path = environment["PARCEL_REALITY_RELAUNCH_RECEIPT"], path.hasPrefix("/"), !path.contains("\0") else { return nil } return URL(fileURLWithPath: path) }
func write(to url: URL) throws { try JSONEncoder().encode(self).write(to: url, options: .atomic) }
@MainActor static func recordReplacement(_ application: NSRunningApplication, parent: Int32) throws { guard let url else { return } var receipt = try JSONDecoder().decode(Self.self, from: Data(contentsOf: url)) guard receipt.parent == parent, receipt.helper == getpid(), receipt.bundlePath == Bundle.main.bundleURL.resolvingSymlinksInPath().path else { throw CocoaError(.fileReadCorruptFile) } receipt.replacement = application.processIdentifier receipt.launchDate = application.launchDate try receipt.write(to: url) } }#endif