This commit is contained in:
Alin
2024-06-24 11:37:48 -06:00
parent 3232c81e80
commit 4da74556de
11 changed files with 131 additions and 19 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ class AppInfoFetcher {
let system = !path.path.contains(NSHomeDirectory())
return AppInfo(id: UUID(), path: path, bundleIdentifier: bundleIdentifier, appName: appName, appVersion: appVersion, appIcon: appIcon,
webApp: webApp, wrapped: wrapped, system: system, bundleSize: 0, files: [], fileSize: [:], fileSizeLogical: [:], fileIcon: [:])
webApp: webApp, wrapped: wrapped, system: system, arch: .empty, bundleSize: 0, files: [], fileSize: [:], fileSizeLogical: [:], fileIcon: [:])
}
private static func fetchAppIcon(for path: URL, wrapped: Bool) -> NSImage? {
+10 -4
View File
@@ -33,10 +33,16 @@ class AppPathFinder {
func findPaths() {
Task(priority: .background) {
self.initialURLProcessing()
self.collectDirectories()
self.collectFiles()
self.finalizeCollection()
if self.appInfo.webApp {
self.initialURLProcessing()
self.finalizeCollection()
} else {
self.initialURLProcessing()
self.collectDirectories()
self.collectFiles()
self.finalizeCollection()
}
}
}
+9 -2
View File
@@ -48,6 +48,7 @@ class AppState: ObservableObject {
webApp: false,
wrapped: false,
system: false,
arch: .empty,
bundleSize: 0,
files: [],
fileSize: [:],
@@ -100,6 +101,7 @@ struct AppInfo: Identifiable, Equatable, Hashable {
let webApp: Bool
let wrapped: Bool
let system: Bool
var arch: Arch
var bundleSize: Int64
var files: [URL]
var fileSize: [URL:Int64]
@@ -115,7 +117,7 @@ struct AppInfo: Identifiable, Equatable, Hashable {
}
static let empty = AppInfo(id: UUID(), path: URL(fileURLWithPath: ""), bundleIdentifier: "", appName: "", appVersion: "", appIcon: nil, webApp: false, wrapped: false, system: false, bundleSize: 0, files: [], fileSize: [:], fileSizeLogical: [:], fileIcon: [:])
static let empty = AppInfo(id: UUID(), path: URL(fileURLWithPath: ""), bundleIdentifier: "", appName: "", appVersion: "", appIcon: nil, webApp: false, wrapped: false, system: false, arch: .empty, bundleSize: 0, files: [], fileSize: [:], fileSizeLogical: [:], fileIcon: [:])
}
@@ -141,7 +143,12 @@ struct ZombieFile: Identifiable, Equatable, Hashable {
}
enum Arch {
case arm
case intel
case universal
case empty
}
enum CurrentTabView:Int
+44
View File
@@ -252,6 +252,50 @@ func isRestricted(atPath path: URL) -> Bool {
}
// Check app bundle architecture
func checkAppBundleArchitecture(at appBundlePath: String) -> Arch {
let bundleURL = URL(fileURLWithPath: appBundlePath)
let executableName: String
// Extract the executable name from Info.plist
let infoPlistPath = bundleURL.appendingPathComponent("Contents/Info.plist")
if let infoPlist = NSDictionary(contentsOf: infoPlistPath) as? [String: Any],
let bundleExecutable = infoPlist["CFBundleExecutable"] as? String {
executableName = bundleExecutable
} else {
return .empty
}
let executablePath = bundleURL.appendingPathComponent("Contents/MacOS/\(executableName)").path
let task = Process()
task.launchPath = "/usr/bin/lipo"
task.arguments = ["-archs", executablePath]
let pipe = Pipe()
task.standardOutput = pipe
task.launch()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
task.waitUntilExit()
if let output = String(data: data, encoding: .utf8) {
let architectures = output.trimmingCharacters(in: .whitespacesAndNewlines).components(separatedBy: " ")
if architectures.contains("x86_64") && architectures.contains("arm64") {
return .universal
} else if architectures.contains("x86_64") {
return .intel
} else if architectures.contains("arm64") {
return .arm
}
}
return .empty
}
// Convert icon to png so colors render correctly
func convertICNSToPNG(icon: NSImage, size: NSSize) -> NSImage? {
// Resize the icon to the specified size