]> granicus.if.org Git - transmission/commitdiff
use NSFileManager to read/write the torrent history in the Application Support direct...
authorMitchell Livingston <livings124@transmissionbt.com>
Sat, 21 Jan 2012 23:28:34 +0000 (23:28 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Sat, 21 Jan 2012 23:28:34 +0000 (23:28 +0000)
macosx/Controller.m

index 3f6188b179dcb98a6b0941eb96c171d6464c15a6..ea503cfac35d0db91232b91cf1ed195b7e72882c 100644 (file)
@@ -126,7 +126,7 @@ typedef enum
 
 #define UPDATE_UI_SECONDS   1.0
 
-#define TRANSFER_PLIST  @"/Library/Application Support/Transmission/Transfers.plist"
+#define TRANSFER_PLIST  @"Transfers.plist"
 
 #define WEBSITE_URL @"http://www.transmissionbt.com/"
 #define FORUM_URL   @"http://forum.transmissionbt.com/"
@@ -418,8 +418,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         NSLog(@"Could not IORegisterForSystemPower");
     
     //load previous transfers
-    NSArray * history = [NSArray arrayWithContentsOfFile: [NSHomeDirectory() stringByAppendingPathComponent: TRANSFER_PLIST]];
-    
+    NSURL * historyURL = [[[[[NSFileManager defaultManager] URLsForDirectory: NSApplicationSupportDirectory inDomains: NSUserDomainMask] objectAtIndex: 0] URLByAppendingPathComponent: @"Transmission"] URLByAppendingPathComponent: TRANSFER_PLIST];
+    NSArray * history = [NSArray arrayWithContentsOfURL: historyURL];
     if (!history)
     {
         //old version saved transfer info in prefs file
@@ -1832,7 +1832,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     for (Torrent * torrent in fTorrents)
         [history addObject: [torrent history]];
     
-    [history writeToFile: [NSHomeDirectory() stringByAppendingPathComponent: TRANSFER_PLIST] atomically: YES];
+    NSURL * historyURL = [[[[[NSFileManager defaultManager] URLsForDirectory: NSApplicationSupportDirectory inDomains: NSUserDomainMask] objectAtIndex: 0] URLByAppendingPathComponent: @"Transmission"] URLByAppendingPathComponent: TRANSFER_PLIST];
+    [history writeToURL: historyURL atomically: YES];
 }
 
 - (void) setSort: (id) sender