mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Use contentsOfDirectory(at:...) instead of atPath:..., and rename apps to bundles.
This commit is contained in:
1 parent
52e2ef88eb
commit
3690dd028a
1 file changed
+8
-9
@@ -65,23 +65,22 @@ class ArchiveItem: CustomStringConvertible {
|
||||
}
|
||||
|
||||
convenience init(fromArchive archivePath: URL, unarchivedDir: URL) throws {
|
||||
let items = try FileManager.default.contentsOfDirectory(atPath: unarchivedDir.path)
|
||||
.filter({ !$0.hasPrefix(".") })
|
||||
.map({ unarchivedDir.appendingPathComponent($0) })
|
||||
let resourceKeys = [URLResourceKey.typeIdentifierKey]
|
||||
let items = try FileManager.default.contentsOfDirectory(at: unarchivedDir, includingPropertiesForKeys: resourceKeys, options: .skipsHiddenFiles)
|
||||
|
||||
let apps = items.filter({
|
||||
if let resourceValues = try? $0.resourceValues(forKeys: [URLResourceKey.typeIdentifierKey]) {
|
||||
let bundles = items.filter({
|
||||
if let resourceValues = try? $0.resourceValues(forKeys: Set(resourceKeys)) {
|
||||
return UTTypeConformsTo(resourceValues.typeIdentifier! as CFString, kUTTypeBundle)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
});
|
||||
if apps.count > 0 {
|
||||
if apps.count > 1 {
|
||||
throw makeError(code: .unarchivingError, "Too many bundles in \(unarchivedDir.path) \(apps)");
|
||||
if bundles.count > 0 {
|
||||
if bundles.count > 1 {
|
||||
throw makeError(code: .unarchivingError, "Too many bundles in \(unarchivedDir.path) \(bundles)");
|
||||
}
|
||||
|
||||
let appPath = apps[0];
|
||||
let appPath = bundles[0];
|
||||
guard let infoPlist = NSDictionary(contentsOf: appPath.appendingPathComponent("Contents/Info.plist")) else {
|
||||
throw makeError(code: .unarchivingError, "No plist \(appPath.path)");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user