]> git.saurik.com Git - cydia.git/commitdiff
Remove all broken hardcoded usage of Cache folder.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 20 May 2019 00:29:26 +0000 (17:29 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 20 May 2019 00:29:26 +0000 (17:29 -0700)
MobileCydia.mm
Sources.h
Sources.mm
postinst.mm

index 22c12725e31ea702a761316d7be43fd12ed64805..4b82efb33bfe31b7e71d4921870c8076de1352f9 100644 (file)
@@ -230,10 +230,6 @@ NSString *Elision_;
 static NSString *Error_;
 static NSString *Warning_;
 
-static NSString *Cache_;
-#define Cache(file) \
-    [NSString stringWithFormat:@"%@/%s", Cache_, file]
-
 static void (*$SBSSetInterceptsMenuButtonForever)(bool);
 static NSData *(*$SBSCopyIconImagePNGDataForDisplayIdentifier)(NSString *);
 
@@ -680,8 +676,8 @@ static CFLocaleRef Locale_;
 static NSArray *Languages_;
 static CGColorSpaceRef space_;
 
-#define CacheState_ "/var/mobile/Library/Caches/com.saurik.Cydia/CacheState.plist"
-#define SavedState_ "/var/mobile/Library/Caches/com.saurik.Cydia/SavedState.plist"
+#define CacheState_ Cache("CacheState.plist")
+#define SavedState_ Cache("SavedState.plist")
 
 static NSDictionary *SectionMap_;
 static _H<NSDate> Backgrounded_;
@@ -3631,7 +3627,7 @@ class CydiaLogCleaner :
         closedir(sources);
     }
 
-    error |= [self popErrorWithTitle:title forOperation:list.ReadAppend(SOURCES_LIST)];
+    error |= [self popErrorWithTitle:title forOperation:list.ReadAppend([SOURCES_LIST UTF8String])];
 
     return error;
 }
@@ -4087,7 +4083,7 @@ class CydiaLogCleaner :
 
         [[NSDictionary dictionaryWithObjectsAndKeys:
             [NSDate date], @"LastUpdate",
-        nil] writeToFile:CacheState_ atomically:YES];
+        nil] writeToFile:CacheState_ atomically:YES];
     }
 
     [delegate_ performSelectorOnMainThread:@selector(releaseNetworkActivityIndicator) withObject:nil waitUntilDone:YES];
@@ -8270,7 +8266,7 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi
 - (void) _refreshIfPossible {
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
-    NSDate *update([[NSDictionary dictionaryWithContentsOfFile:CacheState_] objectForKey:@"LastUpdate"]);
+    NSDate *update([[NSDictionary dictionaryWithContentsOfFile:CacheState_] objectForKey:@"LastUpdate"]);
 
     bool recently = false;
     if (update != nil) {
@@ -8861,7 +8857,7 @@ _end
         @"InterfaceState", [tabbar_ navigationURLCollection],
         @"LastClosed", [NSDate date],
         @"InterfaceIndex", [NSNumber numberWithInt:[tabbar_ selectedIndex]],
-    nil] writeToFile:SavedState_ atomically:YES];
+    nil] writeToFile:SavedState_ atomically:YES];
 
     [self _saveConfig];
 }
@@ -9070,7 +9066,7 @@ _trace();
     [self refreshIfPossible];
     [self disemulate];
 
-    NSDictionary *state([NSDictionary dictionaryWithContentsOfFile:SavedState_]);
+    NSDictionary *state([NSDictionary dictionaryWithContentsOfFile:SavedState_]);
 
     int savedIndex = [[state objectForKey:@"InterfaceIndex"] intValue];
     NSArray *saved = [[[state objectForKey:@"InterfaceState"] mutableCopy] autorelease];
@@ -9417,9 +9413,9 @@ int main(int argc, char *argv[]) {
 
         Version_ = [NSNumber numberWithUnsignedInt:1];
 
-        if (NSMutableDictionary *cache = [NSMutableDictionary dictionaryWithContentsOfFile:CacheState_]) {
+        if (NSMutableDictionary *cache = [NSMutableDictionary dictionaryWithContentsOfFile:CacheState_]) {
             [cache removeObjectForKey:@"LastUpdate"];
-            [cache writeToFile:CacheState_ atomically:YES];
+            [cache writeToFile:CacheState_ atomically:YES];
         }
     }
 
@@ -9456,7 +9452,7 @@ int main(int argc, char *argv[]) {
             _assert(errno == ENOENT);
     }
 
-    system("/usr/libexec/cydia/cydo /bin/ln -sf /var/mobile/Library/Caches/com.saurik.Cydia/sources.list /etc/apt/sources.list.d/cydia.list");
+    system([[NSString stringWithFormat:@"/usr/libexec/cydia/cydo /bin/ln -sf %@ /etc/apt/sources.list.d/cydia.list", Cache("sources.list")] UTF8String]);
 
     /* APT Initialization {{{ */
     _assert(pkgInitConfig(*_config));
index 2defaf6b36889b58462a84d700db5e977a3e2210..c3de58a8b547db5bc0ca485f3e97360429bb30c8 100644 (file)
--- a/Sources.h
+++ b/Sources.h
@@ -28,6 +28,9 @@ void CydiaWriteSources();
 void CydiaAddSource(NSDictionary *source);
 void CydiaAddSource(NSString *href, NSString *distribution, NSArray *sections = nil);
 
-#define SOURCES_LIST "/var/mobile/Library/Caches/com.saurik.Cydia/sources.list"
+extern NSString *Cache_;
+NSString *Cache(const char *file);
+
+#define SOURCES_LIST Cache("sources.list")
 
 #endif//Sources_H
index a156ee2f404e1e73aa09cfeafff15d91f8e6d908..418ea081914ce604b96abcc4010a70fe5030ab25 100644 (file)
 
 #include "Sources.h"
 
+NSString *Cache_;
+
+NSString *Cache(const char *file) {
+    return [NSString stringWithFormat:@"%@/%s", Cache_, file];
+}
+
 extern _H<NSMutableDictionary> Sources_;
 
 void CydiaWriteSources() {
-    unlink(SOURCES_LIST);
-    FILE *file(fopen(SOURCES_LIST, "w"));
+    auto sources([SOURCES_LIST UTF8String]);
+    unlink(sources);
+    FILE *file(fopen(sources, "w"));
     _assert(file != NULL);
 
     fprintf(file, "deb http://apt.saurik.com/ ios/%.2f main\n", kCFCoreFoundationVersionNumber);
index f826f4ff3c9ffdf5b138179dc1c533e512613aad..3cd8cdfc26a4f2a2acd43837db98474f25af302f 100644 (file)
@@ -3,8 +3,6 @@
 #include <dirent.h>
 #include <strings.h>
 
-#include <Sources.h>
-
 #include <sys/stat.h>
 #include <sys/sysctl.h>
 #include <sys/types.h>