mirror of
https://github.com/xtool-org/xtool.git
synced 2026-11-14 11:35:03 +03:00
23 lines
790 B
Swift
23 lines
790 B
Swift
import Foundation
|
|
|
|
package enum XToolCache {
|
|
package static var directory: URL {
|
|
let env = ProcessInfo.processInfo.environment
|
|
if let tmpdir = env["XTL_TMPDIR"], !tmpdir.isEmpty {
|
|
return URL(fileURLWithPath: tmpdir).appendingPathComponent("sh.xtool")
|
|
}
|
|
#if os(Linux)
|
|
let xdgCache: URL
|
|
if let xdgCachePath = env["XDG_CACHE_HOME"],
|
|
(xdgCachePath as NSString).isAbsolutePath {
|
|
xdgCache = URL(filePath: xdgCachePath)
|
|
} else {
|
|
xdgCache = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent(".cache")
|
|
}
|
|
return xdgCache.appending(component: "xtool")
|
|
#else
|
|
return URL.cachesDirectory.appending(component: "sh.xtool")
|
|
#endif
|
|
}
|
|
}
|