I'm writing an app for copying files and folders over the network to a client computer. Everything else works just peachy. It's that I don't know how to go about the file copying - I looked at NSFileManager, but it seems that this would need the network drive mounted. My goal is to simulate something like Remote Desktop's Copy File dialog, very transparently. Any ideas/help?
EDIT: Looks like an SCP wrapper, or the SCP command with NSTask may help me. Still wondering how, though :[
It is a bit unclear if you want to know how to use NSTask, or use SCP in it.
But here is a simple example of using NSTask. Each argument for the command has to be put in an Array. so for example the command for
/bin/cp -R /Users/userName/Desktop/fooFolder/fooFile.foo /Users/suerName/Desktop/fooCopyToFolder
Would be done like this.
NSPipe *output;
NSTask *task;
task = [[NSTask alloc] init];
NSString* cpPath = @"/bin/cp";
NSString* sourcePath =@"/Users/userName/Desktop/fooFolder/fooFile.foo";
NSString* finalPath = @"/Users/suerName/Desktop/fooCopyToFolder";
[task setLaunchPath:cpPath];
[task setArguments:[NSArray arrayWithObjects:@"-R",sourcePath ,finalPath, nil]];
output = [[NSPipe alloc] init];
[task setStandardOutput:output];
[task setStandardInput:[NSPipe pipe]];
[task launch];
[task waitUntilExit];
int status = [task terminationStatus];
if (status == 0) {
NSLog(@"task succeeded. %i",status);
} else {
NSLog(@"task failed.%i",status);
;
}