1 @interface NSMutableArray (Cydia)
2 - (void) addInfoDictionary:(NSDictionary *)info;
5 @implementation NSMutableArray (Cydia)
7 - (void) addInfoDictionary:(NSDictionary *)info {
13 @interface NSMutableDictionary (Cydia)
14 - (void) addInfoDictionary:(NSDictionary *)info;
17 @implementation NSMutableDictionary (Cydia)
19 - (void) addInfoDictionary:(NSDictionary *)info {
20 NSString *bundle = [info objectForKey:@"CFBundleIdentifier"];
21 [self setObject:info forKey:bundle];
26 #define Cache_ "/User/Library/Caches/com.apple.mobile.installation.plist"
29 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
31 if (NSMutableDictionary *cache = [[NSMutableDictionary alloc] initWithContentsOfFile:@ Cache_]) {
34 NSFileManager *manager = [NSFileManager defaultManager];
37 id system = [cache objectForKey:@"System"];
42 if (stat(Cache_, &info) == -1)
45 [system removeAllObjects];
47 if (NSArray *apps = [manager contentsOfDirectoryAtPath:@"/Applications" error:&error]) {
48 for (NSString *app in apps)
49 if ([app hasSuffix:@".app"]) {
50 NSString *path = [@"/Applications" stringByAppendingPathComponent:app];
51 NSString *plist = [path stringByAppendingPathComponent:@"Info.plist"];
52 if (NSMutableDictionary *info = [[NSMutableDictionary alloc] initWithContentsOfFile:plist]) {
54 [info setObject:path forKey:@"Path"];
55 [info setObject:@"System" forKey:@"ApplicationType"];
56 [system addInfoDictionary:info];
61 [cache writeToFile:@Cache_ atomically:YES];
63 if (chown(Cache_, info.st_uid, info.st_gid) == -1)
65 if (chmod(Cache_, info.st_mode) == -1)
69 fprintf(stderr, "%s\n", error == nil ? strerror(errno) : [[error localizedDescription] UTF8String]);
72 notify_post("com.apple.mobile.application_installed");