File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,15 +26,7 @@ extension AppOverrides: Codable {
2626
2727enum AppOverridesState {
2828 private static func url( ) -> URL ? {
29- guard let appSupport = try ? FileManager . default. url (
30- for: . applicationSupportDirectory,
31- in: . userDomainMask,
32- appropriateFor: nil ,
33- create: false ,
34- ) else { return nil }
35- return appSupport
36- . appendingPathComponent ( Log . subsystem, isDirectory: true )
37- . appendingPathComponent ( " apps.json " )
29+ subsystemSupportURL ( " apps.json " )
3830 }
3931
4032 static func read( ) -> AppOverrides {
Original file line number Diff line number Diff line change @@ -127,15 +127,7 @@ final class HotkeyWatcher {
127127/// shutdown so a stale value doesn't outlive the daemon.
128128enum HotkeyState {
129129 private static func url( ) -> URL ? {
130- guard let appSupport = try ? FileManager . default. url (
131- for: . applicationSupportDirectory,
132- in: . userDomainMask,
133- appropriateFor: nil ,
134- create: false ,
135- ) else { return nil }
136- return appSupport
137- . appendingPathComponent ( Log . subsystem, isDirectory: true )
138- . appendingPathComponent ( " hotkey.state " )
130+ subsystemSupportURL ( " hotkey.state " )
139131 }
140132
141133 static func write( _ state: String ) {
Original file line number Diff line number Diff line change @@ -12,15 +12,7 @@ enum Mode: String {
1212/// Default is `.smart` when the file is missing or malformed.
1313enum ModeState {
1414 private static func url( ) -> URL ? {
15- guard let appSupport = try ? FileManager . default. url (
16- for: . applicationSupportDirectory,
17- in: . userDomainMask,
18- appropriateFor: nil ,
19- create: false ,
20- ) else { return nil }
21- return appSupport
22- . appendingPathComponent ( Log . subsystem, isDirectory: true )
23- . appendingPathComponent ( " mode " )
15+ subsystemSupportURL ( " mode " )
2416 }
2517
2618 static func read( ) -> Mode {
Original file line number Diff line number Diff line change 1- // Filesystem paths used at runtime to locate the vendored
2- // mediaremote-adapter script and MediaRemoteAdapter.framework.
1+ // Filesystem path resolution used at runtime: the vendored
2+ // mediaremote-adapter artifacts, and the Application Support directory
3+ // backing the on-disk `*State` stores.
34
45import Foundation
56
7+ /// `~/Library/Application Support/<subsystem>/<name>`, or nil if it
8+ /// can't be resolved. Shared by the `*State` stores.
9+ func subsystemSupportURL( _ name: String ) -> URL ? {
10+ guard let appSupport = try ? FileManager . default. url (
11+ for: . applicationSupportDirectory,
12+ in: . userDomainMask,
13+ appropriateFor: nil ,
14+ create: false ,
15+ ) else { return nil }
16+ return appSupport
17+ . appendingPathComponent ( Log . subsystem, isDirectory: true )
18+ . appendingPathComponent ( name)
19+ }
20+
621struct AdapterArtifacts {
722 let scriptPath : String
823 let frameworkPath : String
You can’t perform that action at this time.
0 commit comments