私はそれの地獄のために小さなRSyncプログラムをまとめようとしています、そして私はそれを以下のコードで動作させることができました。唯一の問題は、ディレクトリではなく、単一のファイルのみをRsyncすることです。terminalコマンドを実行rsync
すると、ディレクトリ全体を他のディレクトリにコピーできます。誰かが修正を知っていますか?
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];
ソースとデスティネーションに2つのテキストフィールドがあり、文字列値を取得して、ソースとデスティネーションに等しく設定します。