summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2012-06-01 05:31:15 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2012-06-01 05:31:15 +0000
commit0183260a5f128e3a0a5331ce89f7e88aa79feb2e (patch)
tree5227f2d525172274d09e6f352df17a03188ac3fa
parent43318ffe18750983058829ee0224d7328a5252a8 (diff)
Invalidate the Launch Services icon cache.
-rw-r--r--uicache.mm13
1 files changed, 8 insertions, 5 deletions
diff --git a/uicache.mm b/uicache.mm
index 5cc1a15..28c518d 100644
--- a/uicache.mm
+++ b/uicache.mm
@@ -88,7 +88,7 @@ int main(int argc, const char *argv[]) {
NSFileManager *manager = [NSFileManager defaultManager];
NSError *error = nil;
- NSMutableArray *bundles([NSMutableArray arrayWithCapacity:16]);
+ NSMutableDictionary *bundles([NSMutableDictionary dictionaryWithCapacity:16]);
id system = [cache objectForKey:@"System"];
if (system == nil)
@@ -103,8 +103,8 @@ int main(int argc, const char *argv[]) {
NSString *plist = [path stringByAppendingPathComponent:@"Info.plist"];
if (NSMutableDictionary *info = [NSMutableDictionary dictionaryWithContentsOfFile:plist]) {
- if ([info objectForKey:@"CFBundleIdentifier"] != nil) {
- [bundles addObject:path];
+ if (NSString *identifier = [info objectForKey:@"CFBundleIdentifier"]) {
+ [bundles setObject:path forKey:identifier];
[info setObject:path forKey:@"Path"];
[info setObject:@"System" forKey:@"ApplicationType"];
[system addInfoDictionary:info];
@@ -118,8 +118,11 @@ int main(int argc, const char *argv[]) {
if (workspace != nil)
for (NSString *bundle in bundles) {
- [workspace unregisterApplication:[NSURL fileURLWithPath:bundle]];
- [workspace registerApplication:[NSURL fileURLWithPath:bundle]];
+ NSString *path([bundles objectForKey:identifier]);
+ [workspace unregisterApplication:[NSURL fileURLWithPath:path]];
+ if ([workspace respondsToSelector:@selector(invalidateIconCache:)])
+ [workspace invalidateIconCache:identifier];
+ [workspace registerApplication:[NSURL fileURLWithPath:path]];
}
if (false) error: