summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2008-09-14 21:08:55 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2008-09-14 21:08:55 +0000
commit7fb7ce13deab7a4d127f5f04e0c82069a6cf2014 (patch)
tree33080782b2aa1b35ae339db0f29cdb8bb9327e88
parent1094bdcb9288d51f5dae9194d2f5adcfa3273040 (diff)
Added UICache.
-rw-r--r--makefile2
-rw-r--r--uicache.mm (renamed from uiinstall.mm)26
2 files changed, 13 insertions, 15 deletions
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
index 1473ca5..71f67d8 100644
--- a/uiinstall.mm
+++ b/uicache.mm
@@ -1,3 +1,10 @@
+#import <Foundation/Foundation.h>
+
+#include <notify.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
@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");