I'm trying to put together a little RSync program for the hell of it, and I managed to get it to work with the code below. The only problem is that it only Rsyncs single files and not directories. If you run rsync
through the terminal command it can copy entire directories into other directories. Anyone know a fix?
NSString *source = self.source.stringValue;
NSString *destination = self.destination.stringValue;
NSLog(@"The source is %@. The destination is %@.", source, destination);
NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/bin/rsync"];
NSArray *arguments;
arguments = [NSArray arrayWithObjects: source, destination, nil];
[task setArguments: arguments];
NSPipe *pipe;
pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
NSFileHandle *file;
file = [pipe fileHandleForReading];
[task launch];
NSData *data;
data = [file readDataToEndOfFile];
I have two text fields for the source and destination which I take the string value and set those equal to the source and destination.