refactor: Fix macOS standalone application

This commit is contained in:
世界
2026-01-05 01:21:24 +08:00
parent ef1c924c64
commit 59317f3c79
66 changed files with 2799 additions and 585 deletions
@@ -0,0 +1,42 @@
import Foundation
import Library
enum WorkingDirectoryManager {
private static var workingDirectoryPath: String {
"/var/root/Library/Containers/\(AppConfiguration.systemExtensionBundleID)/Data/Working"
}
static func getSize() -> Int64 {
let path = workingDirectoryPath
guard FileManager.default.fileExists(atPath: path) else {
return 0
}
var totalSize: Int64 = 0
let enumerator = FileManager.default.enumerator(atPath: path)
while let file = enumerator?.nextObject() as? String {
let filePath = (path as NSString).appendingPathComponent(file)
if let attrs = try? FileManager.default.attributesOfItem(atPath: filePath),
let size = attrs[.size] as? Int64
{
totalSize += size
}
}
return totalSize
}
static func clean() throws {
let path = workingDirectoryPath
guard FileManager.default.fileExists(atPath: path) else {
return
}
let contents = try FileManager.default.contentsOfDirectory(atPath: path)
for item in contents {
let itemPath = (path as NSString).appendingPathComponent(item)
try FileManager.default.removeItem(atPath: itemPath)
}
}
}