From 7fb7ce13deab7a4d127f5f04e0c82069a6cf2014 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 14 Sep 2008 21:08:55 +0000 Subject: [PATCH 1/1] Added UICache. --- makefile | 2 +- uiinstall.mm => uicache.mm | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 15 deletions(-) rename uiinstall.mm => uicache.mm (82%) diff --git a/makefile b/makefile index cf9cbd0..60cb272 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,4 @@ -all: uiduid uishoot +all: uiduid uishoot uicache %: %.mm $${PKG_TARG}-g++ -o $@ $< -framework CoreFoundation -framework Foundation -framework UIKit -lobjc diff --git a/uiinstall.mm b/uicache.mm similarity index 82% rename from uiinstall.mm rename to uicache.mm index 1473ca5..71f67d8 100644 --- a/uiinstall.mm +++ b/uicache.mm @@ -1,3 +1,10 @@ +#import + +#include +#include +#include +#include + @interface NSMutableArray (Cydia) - (void) addInfoDictionary:(NSDictionary *)info; @end @@ -23,12 +30,12 @@ @end -#define Cache_ "/User/Library/Caches/com.apple.mobile.installation.plist" - int main() { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - if (NSMutableDictionary *cache = [[NSMutableDictionary alloc] initWithContentsOfFile:@ Cache_]) { + NSString *path([NSString stringWithFormat:@"%@/Library/Caches/com.apple.mobile.installation.plist", NSHomeDirectory()]); + + if (NSMutableDictionary *cache = [[NSMutableDictionary alloc] initWithContentsOfFile:path]) { [cache autorelease]; NSFileManager *manager = [NSFileManager defaultManager]; @@ -38,10 +45,6 @@ int main() { if (system == nil) goto error; - struct stat info; - if (stat(Cache_, &info) == -1) - goto error; - [system removeAllObjects]; if (NSArray *apps = [manager contentsOfDirectoryAtPath:@"/Applications" error:&error]) { @@ -58,16 +61,11 @@ int main() { } } else goto error; - [cache writeToFile:@Cache_ atomically:YES]; - - if (chown(Cache_, info.st_uid, info.st_gid) == -1) - goto error; - if (chmod(Cache_, info.st_mode) == -1) - goto error; + [cache writeToFile:path atomically:YES]; if (false) error: fprintf(stderr, "%s\n", error == nil ? strerror(errno) : [[error localizedDescription] UTF8String]); - } + } else fprintf(stderr, "cannot open cache file. incorrect user?\n"); notify_post("com.apple.mobile.application_installed"); -- 2.45.2