Changeset 13334


Ignore:
Timestamp:
Jun 3, 2012, 11:29:39 PM (9 years ago)
Author:
livings124
Message:

revert 13327 (#4924)

Location:
trunk/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/AddWindowController.h

    r13327 r13334  
    4646   
    4747    Torrent * fTorrent;
    48     NSURL * fTorrentFile;
    49     NSString * fDestination;
     48    NSString * fDestination, * fTorrentFile;
    5049    BOOL fLockDestination;
    5150   
  • trunk/macosx/AddWindowController.m

    r13327 r13334  
    6666        fController = controller;
    6767       
    68         fTorrentFile = [[NSURL alloc] initFileURLWithPath: [torrentFile stringByExpandingTildeInPath]];
     68        fTorrentFile = [[torrentFile stringByExpandingTildeInPath] retain];
    6969       
    7070        fDeleteTorrentInitial = deleteTorrent;
  • trunk/macosx/Torrent.h

    r13327 r13334  
    120120- (void) setPriority: (tr_priority_t) priority;
    121121
    122 + (void) trashFile: (NSURL *) fileURL;
     122+ (void) trashFile: (NSString *) path;
    123123- (void) moveTorrentDataFileTo: (NSString *) folder;
    124124- (void) copyTorrentFileTo: (NSString *) path;
  • trunk/macosx/Torrent.m

    r13327 r13334  
    9595    @autoreleasepool
    9696    {
    97         NSLog(@"%s", filename);
    9897        if (filename != NULL)
    99         {
    100             [Torrent trashFile: [NSURL fileURLWithPath: [NSString stringWithUTF8String: filename]]];
    101             NSLog(@"%@\n%@", [NSString stringWithUTF8String: filename], [NSURL fileURLWithPath: [NSString stringWithUTF8String: filename]]);
     98            [Torrent trashFile: [NSString stringWithUTF8String: filename]];
    10299        }
    103100    }
     
    119116    {
    120117        if (torrentDelete && ![[self torrentLocation] isEqualToString: path])
    121             [Torrent trashFile: [NSURL fileURLWithPath: path]];
     118            [Torrent trashFile: path];
    122119    }
    123120    return self;
     
    497494}
    498495
    499 + (void) trashFile: (NSURL *) fileURL
    500 {
    501     [[NSWorkspace sharedWorkspace] recycleURLs: [NSArray arrayWithObject: fileURL] completionHandler: ^(NSDictionary * newURLs, NSError * error) {
    502         if (error)
    503             NSLog(@"Could not trash %@: %@", [fileURL path], [error localizedDescription]);
    504     }];
     496+ (void) trashFile: (NSString *) path
     497{
     498    //attempt to move to trash
     499    if (![[NSWorkspace sharedWorkspace] performFileOperation: NSWorkspaceRecycleOperation
     500                                                      source: [path stringByDeletingLastPathComponent] destination: @""
     501                                                       files: [NSArray arrayWithObject: [path lastPathComponent]] tag: nil])
     502    {
     503        //if cannot trash, just delete it (will work if it's on a remote volume)
     504        NSError * error;
     505        if (![[NSFileManager defaultManager] removeItemAtPath: path error: &error])
     506            NSLog(@"old Could not trash %@: %@", path, [error localizedDescription]);
     507        else {NSLog(@"old removed %@", path);}
     508    }
    505509}
    506510
Note: See TracChangeset for help on using the changeset viewer.