diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2013-02-06 10:29:39 +0000 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2013-02-06 10:53:29 +0000 |
commit | 1bd75e96ee074964a2d7c4fd1d9bc8ddb0c2be7e (patch) | |
tree | 0af46fed0d6552e19a1617148904b1ddf0b5ebb1 /uicache.mm | |
parent | 3ffcdfdb8076bb82532bb122b0752b0f5dc21078 (diff) |
Unregister totally obsolete applications.
Diffstat (limited to 'uicache.mm')
-rw-r--r-- | uicache.mm | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -60,6 +60,10 @@ [self addObject:info]; } +- (NSArray *) allInfoDictionaries { + return self; +} + @end @interface NSMutableDictionary (Cydia) @@ -73,6 +77,10 @@ [self setObject:info forKey:bundle]; } +- (NSArray *) allInfoDictionaries { + return [self allValues]; +} + @end int main(int argc, const char *argv[]) { @@ -116,6 +124,11 @@ int main(int argc, const char *argv[]) { NSArray *cached([cache objectForKey:@"InfoPlistCachedKeys"]); + NSMutableSet *removed([NSMutableSet set]); + for (NSDictionary *info in [before allInfoDictionaries]) + if (NSString *path = [info objectForKey:@"Path"]) + [removed addObject:path]; + if (NSArray *apps = [manager contentsOfDirectoryAtPath:@"/Applications" error:&error]) { for (NSString *app in apps) if ([app hasSuffix:@".app"]) { @@ -125,6 +138,7 @@ int main(int argc, const char *argv[]) { if (NSMutableDictionary *info = [NSMutableDictionary dictionaryWithContentsOfFile:plist]) { if (NSString *identifier = [info objectForKey:@"CFBundleIdentifier"]) { [bundles setObject:path forKey:identifier]; + [removed removeObject:path]; if (cached != nil) { NSMutableDictionary *merged([before objectForKey:identifier]); @@ -168,6 +182,9 @@ int main(int argc, const char *argv[]) { NSString *path([bundles objectForKey:identifier]); [workspace registerApplication:[NSURL fileURLWithPath:path]]; } + + for (NSString *path in removed) + [workspace unregisterApplication:[NSURL fileURLWithPath:path]]; } } else fprintf(stderr, "cannot open cache file. incorrect user?\n"); cached: |