Modern Apps git

xtool.git

Public
git clone https://git.maproj.org/xtool.git
main ▾

xtool.git / Sources / XUtils / XToolCache.swift

XToolCache.swift22 lines · 790 BRaw
1import Foundation
2
3package enum XToolCache {
4 package static var directory: URL {
5 let env = ProcessInfo.processInfo.environment
6 if let tmpdir = env["XTL_TMPDIR"], !tmpdir.isEmpty {
7 return URL(fileURLWithPath: tmpdir).appendingPathComponent("sh.xtool")
8 }
9 #if os(Linux)
10 let xdgCache: URL
11 if let xdgCachePath = env["XDG_CACHE_HOME"],
12 (xdgCachePath as NSString).isAbsolutePath {
13 xdgCache = URL(filePath: xdgCachePath)
14 } else {
15 xdgCache = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent(".cache")
16 }
17 return xdgCache.appending(component: "xtool")
18 #else
19 return URL.cachesDirectory.appending(component: "sh.xtool")
20 #endif
21 }
22}