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

revert 13327 (#4924)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.