xtool.git
Publicgit clone https://git.maproj.org/xtool.gitxtool.git / Sources / XKit / Utilities / DirectoryProvider.swift
DirectoryProvider.swift18 lines · 530 BRaw
| 1 | import Foundation |
| 2 | import Dependencies |
| 3 | |
| 4 | private struct PersistentDirectoryProvider: DependencyKey, Sendable { |
| 5 | var directory: URL |
| 6 | |
| 7 | static let liveValue = PersistentDirectoryProvider( |
| 8 | directory: URL(fileURLWithPath: NSHomeDirectory()) |
| 9 | .appendingPathComponent(".config/xtool") |
| 10 | ) |
| 11 | } |
| 12 | |
| 13 | extension DependencyValues { |
| 14 | public var persistentDirectory: URL { |
| 15 | get { self[PersistentDirectoryProvider.self].directory } |
| 16 | set { self[PersistentDirectoryProvider.self].directory = newValue } |
| 17 | } |
| 18 | } |