Using caches directory for sync archive and temporary files.
authorMiltiadis Vasilakis <mvasilak@gmail.com>
Thu, 1 Dec 2011 13:26:11 +0000 (15:26 +0200)
committerMiltiadis Vasilakis <mvasilak@gmail.com>
Thu, 1 Dec 2011 13:26:11 +0000 (15:26 +0200)
pithos-macos/PithosSyncDaemon.m

index cd6f498..5bcd3fa 100644 (file)
 
 - (NSString *)pithosStateFilePath {
     if (!pithosStateFilePath)
-        pithosStateFilePath = [[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"PithosLocalObjectStates.archive"] retain];
+        pithosStateFilePath = [[[[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] 
+                                 stringByAppendingPathComponent:[[NSBundle mainBundle] bundleIdentifier]] 
+                                stringByAppendingPathComponent:@"PithosLocalObjectStates.archive"] retain];
     return [[pithosStateFilePath copy] autorelease];
 }
 
                 [fileManager createDirectoryAtPath:tempDownloadsDirPath withIntermediateDirectories:YES attributes:nil error:&error];
             if (error)
                 tempDownloadsDirPath = nil;
-            }
+        }
         if (!tempDownloadsDirPath) {
-            NSString *tempDirTemplate = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Temp Downloads XXXXXX"];
+            NSString *tempDirTemplate = [[[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] 
+                                          stringByAppendingPathComponent:[[NSBundle mainBundle] bundleIdentifier]] 
+                                         stringByAppendingPathComponent:@"Temp Downloads XXXXXX"];
             const char *tempDirTemplateCString = [tempDirTemplate fileSystemRepresentation];
             char *tempDirNameCString = (char *)malloc(strlen(tempDirTemplateCString) + 1);
             strcpy(tempDirNameCString, tempDirTemplateCString);
                 tempTrashDirPath = nil;
         }
         if (!tempTrashDirPath) {
-            NSString *tempDirTemplate = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Temp Trash XXXXXX"];
+            NSString *tempDirTemplate = [[[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] 
+                                          stringByAppendingPathComponent:[[NSBundle mainBundle] bundleIdentifier]] 
+                                         stringByAppendingPathComponent:@"Temp Trash XXXXXX"];
             const char *tempDirTemplateCString = [tempDirTemplate fileSystemRepresentation];
             char *tempDirNameCString = (char *)malloc(strlen(tempDirTemplateCString) + 1);
             strcpy(tempDirNameCString, tempDirTemplateCString);