]> granicus.if.org Git - transmission/commitdiff
#4839 Use configuration directory retrieved from libtransmission
authorMitchell Livingston <livings124@transmissionbt.com>
Sun, 18 Mar 2012 14:33:50 +0000 (14:33 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Sun, 18 Mar 2012 14:33:50 +0000 (14:33 +0000)
macosx/Controller.h
macosx/Controller.m

index 910985094b4106ce3a1f4109d319b60c7f2969f3..48f4c86715e47991839348e84b4d95fc19d153ff 100644 (file)
@@ -61,6 +61,8 @@ typedef enum
     
     NSUserDefaults                  * fDefaults;
     
+    NSString                        * fConfigDirectory;
+    
     IBOutlet NSWindow               * fWindow;
     DragOverlayWindow               * fOverlayWindow;
     IBOutlet TorrentTableView       * fTableView;
index 7c79c38a69b2e7dbe2a3bd0ce77e94f025a721ae..2e1b310af94e32afc87b74c242aba0c0b4e5bed7 100644 (file)
@@ -324,6 +324,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         fLib = tr_sessionInit("macosx", configDir, YES, &settings);
         tr_bencFree(&settings);
         
+        fConfigDirectory = [[NSString alloc] initWithUTF8String: configDir];
+        
         [NSApp setDelegate: self];
         
         //register for magnet URLs (has to be in init)
@@ -444,8 +446,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         NSLog(@"Could not IORegisterForSystemPower");
     
     //load previous transfers
-    NSURL * historyURL = [[[[[NSFileManager defaultManager] URLsForDirectory: NSApplicationSupportDirectory inDomains: NSUserDomainMask] objectAtIndex: 0] URLByAppendingPathComponent: @"Transmission"] URLByAppendingPathComponent: TRANSFER_PLIST];
-    NSArray * history = [NSArray arrayWithContentsOfURL: historyURL];
+    NSString * historyFile = [fConfigDirectory stringByAppendingPathComponent: TRANSFER_PLIST];
+    NSArray * history = [NSArray arrayWithContentsOfFile: historyFile];
     if (!history)
     {
         //old version saved transfer info in prefs file
@@ -724,6 +726,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     
     [fPreviewPanel release];
     
+    [fConfigDirectory release];
+    
     //complete cleanup
     tr_sessionClose(fLib);
 }
@@ -1903,8 +1907,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     for (Torrent * torrent in fTorrents)
         [history addObject: [torrent history]];
     
-    NSURL * historyURL = [[[[[NSFileManager defaultManager] URLsForDirectory: NSApplicationSupportDirectory inDomains: NSUserDomainMask] objectAtIndex: 0] URLByAppendingPathComponent: @"Transmission"] URLByAppendingPathComponent: TRANSFER_PLIST];
-    [history writeToURL: historyURL atomically: YES];
+    NSString * historyFile = [fConfigDirectory stringByAppendingPathComponent: TRANSFER_PLIST];
+    [history writeToFile: historyFile atomically: YES];
 }
 
 - (void) setSort: (id) sender