I have a Mac (not iOS) application. I want to run a shell command 'find' after the user selects a folder with NSOpenPanel. The following is what I have.
NSString *path = [url path]; NSString *folderName = [path lastPathComponent]; NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:@"/usr/bin/find"]; NSMutableString *command = [[NSMutableString alloc] initWithString:path]; [command appendString:@" -name '._*' -type f "]; NSArray* args = [NSArray arrayWithObjects:@"commit",command,nil]; [task setArguments:args]; NSPipe *pipe; pipe = [NSPipe pipe]; [task setStandardOutput: pipe]; [task launch]; NSFileHandle *file; file = [pipe fileHandleForReading]; NSData *data; data = [file readDataToEndOfFile]; NSString *output = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]; NSLog(@"%@",output); It's my first time running a shell command with a Mac application that is developed with Objective-C. I suppose that I'm on the right track. Anyway, when I select a folder, I get the following debugger output message.
- find: commit: No such file or directory
- find: find: /Volumes/SDHC 16 GB/More -name '._*' -type f : No such file or directory
I suppose that the shell command cannot read this sort of file paths. Do I need to convert it into a shell path or whatever it understand? If so, how?
Thank you for your advice.