mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2025-12-25 12:14:17 +01:00
47 lines
1.5 KiB
Swift
47 lines
1.5 KiB
Swift
import Path
|
|
import Foundation
|
|
|
|
extension Path {
|
|
static let defaultXcodesApplicationSupport = Path.applicationSupport/"com.robotsandpencils.XcodesApp"
|
|
static var xcodesApplicationSupport: Path {
|
|
guard let savedApplicationSupport = Current.defaults.string(forKey: "localPath") else {
|
|
return defaultXcodesApplicationSupport
|
|
}
|
|
guard let path = Path(savedApplicationSupport) else {
|
|
return defaultXcodesApplicationSupport
|
|
}
|
|
return path
|
|
}
|
|
|
|
static var cacheFile: Path {
|
|
return xcodesApplicationSupport/"available-xcodes.json"
|
|
}
|
|
|
|
static let defaultInstallDirectory = Path.root/"Applications"
|
|
|
|
static var installDirectory: Path {
|
|
guard let savedInstallDirectory = Current.defaults.string(forKey: "installPath") else {
|
|
return defaultInstallDirectory
|
|
}
|
|
guard let path = Path(savedInstallDirectory) else {
|
|
return defaultInstallDirectory
|
|
}
|
|
return path
|
|
}
|
|
|
|
static var runtimeCacheFile: Path {
|
|
return xcodesApplicationSupport/"downloadable-runtimes.json"
|
|
}
|
|
|
|
static var xcodesCaches: Path {
|
|
return caches/"com.xcodesorg.xcodesapp"
|
|
}
|
|
|
|
@discardableResult
|
|
func setCurrentUserAsOwner() -> Path {
|
|
let user = ProcessInfo.processInfo.environment["SUDO_USER"] ?? NSUserName()
|
|
try? FileManager.default.setAttributes([.ownerAccountName: user], ofItemAtPath: string)
|
|
return self
|
|
}
|
|
}
|