Changeset 13334 for trunk/macosx/Torrent.m
- Timestamp:
- Jun 3, 2012, 11:29:39 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Torrent.m
r13327 r13334 95 95 @autoreleasepool 96 96 { 97 NSLog(@"%s", filename);98 97 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]]; 102 99 } 103 100 } … … 119 116 { 120 117 if (torrentDelete && ![[self torrentLocation] isEqualToString: path]) 121 [Torrent trashFile: [NSURL fileURLWithPath: path]];118 [Torrent trashFile: path]; 122 119 } 123 120 return self; … … 497 494 } 498 495 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 } 505 509 } 506 510
Note: See TracChangeset
for help on using the changeset viewer.