From 3ffcdfdb8076bb82532bb122b0752b0f5dc21078 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 6 Feb 2013 09:41:58 +0000 Subject: [PATCH] If possible, only merge cached Info.plist keys. --- uicache.mm | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/uicache.mm b/uicache.mm index 1b62d0e..aac264d 100644 --- a/uicache.mm +++ b/uicache.mm @@ -105,13 +105,16 @@ int main(int argc, const char *argv[]) { NSMutableDictionary *bundles([NSMutableDictionary dictionaryWithCapacity:16]); - id system = [cache objectForKey:@"System"]; - if (system == nil) { error: + id after = [cache objectForKey:@"System"]; + if (after == nil) { error: fprintf(stderr, "%s\n", error == nil ? strerror(errno) : [[error localizedDescription] UTF8String]); goto cached; } - [system removeAllObjects]; + id before([[after copy] autorelease]); + [after removeAllObjects]; + + NSArray *cached([cache objectForKey:@"InfoPlistCachedKeys"]); if (NSArray *apps = [manager contentsOfDirectoryAtPath:@"/Applications" error:&error]) { for (NSString *app in apps) @@ -122,9 +125,26 @@ int main(int argc, const char *argv[]) { if (NSMutableDictionary *info = [NSMutableDictionary dictionaryWithContentsOfFile:plist]) { if (NSString *identifier = [info objectForKey:@"CFBundleIdentifier"]) { [bundles setObject:path forKey:identifier]; + + if (cached != nil) { + NSMutableDictionary *merged([before objectForKey:identifier]); + if (merged == nil) + merged = [NSMutableDictionary dictionary]; + else + merged = [[merged mutableCopy] autorelease]; + + for (NSString *key in cached) + if (NSObject *value = [info objectForKey:key]) + [merged setObject:value forKey:key]; + else + [merged removeObjectForKey:key]; + + info = merged; + } + [info setObject:path forKey:@"Path"]; [info setObject:@"System" forKey:@"ApplicationType"]; - [system addInfoDictionary:info]; + [after addInfoDictionary:info]; } else fprintf(stderr, "%s missing CFBundleIdentifier", [app UTF8String]); } -- 2.45.2