mirror of
https://github.com/arsenetar/dupeguru.git
synced 2024-11-16 04:09:02 +00:00
047b4aff0c
--HG-- extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%40102
24 lines
1018 B
Objective-C
24 lines
1018 B
Objective-C
#import <Cocoa/Cocoa.h>
|
|
|
|
int main (int argc, const char * argv[]) {
|
|
if(argc == 1){
|
|
NSLog(@"A file path to send to trash is needed");
|
|
return 1;
|
|
}
|
|
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
|
NSString *filepath = [NSString stringWithCString:argv[1] encoding:NSUTF8StringEncoding];
|
|
NSLog(@"%@",filepath);
|
|
NSMutableArray *split = [NSMutableArray arrayWithArray:[filepath componentsSeparatedByString:@"/"]];
|
|
NSString *filename = [split lastObject];
|
|
[split removeLastObject];
|
|
NSString *dirpath = [split componentsJoinedByString:@"/"];
|
|
int result;
|
|
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation
|
|
source:dirpath
|
|
destination:@""
|
|
files:[NSArray arrayWithObject:filename]
|
|
tag:&result];
|
|
[pool drain];
|
|
return result;
|
|
}
|