static int dm_sendFileToOtherMachine_chunkSize = 100*1024; // 1024*1024; svoid dm_sendFileToOtherMachine(File f, S computerID, S remotePath) { dm_evalOnOtherMachine(computerID, formatFunctionCallWithSemicolon backupFile( formatFunctionCall fileRelativeToUserDirUnlessAbsolute(quote(remotePath)) )); for (LongRange r : chunks(fileSize(f), dm_sendFileToOtherMachine_chunkSize)) { print("Sending file chunk " + r + " of " + f + " to " + computerID + ":" + remotePath); dm_evalOnOtherMachine(computerID, formatFunctionCallWithSemicolon saveBinaryFilePart_base64( formatFunctionCall fileRelativeToUserDirUnlessAbsolute(quote(remotePath)), r.start + "L", quote(base64encode(loadBinaryFileChunk(f, r))))); } dm_evalOnOtherMachine(computerID, formatFunctionCallWithSemicolon truncateFile( formatFunctionCall fileRelativeToUserDirUnlessAbsolute(quote(remotePath)), fileSize(f) + "L")); } // works only for files under user dir. sends them to same path // in remote user dir. svoid dm_sendFileToOtherMachine(File f, S computerID) { S path = assertNotNull(f2s(f) + " is not in " + userDir(), pathRelativeToUserDir(f)); dm_sendFileToOtherMachine(f, computerID, path); }