]> SALOME platform Git repositories - tools/libbatch.git/blobdiff - src/Core/CommunicationProtocol.cxx
Salome HOME
Add rsync as a new protocol for copy.
[tools/libbatch.git] / src / Core / CommunicationProtocol.cxx
index 57a1d527e70a12c7c190a8e90bc8d754a7a51d51..1e50417926fd6fb98fd06eb54c8fdcf12c5618c0 100644 (file)
 #ifdef HAS_SSH
  #include "CommunicationProtocolSSH.hxx"
 #endif
+#ifdef HAS_RSYNC
+ #include "CommunicationProtocolRsync.hxx"
+#endif
 #include "APIInternalFailureException.hxx"
 #include "RunTimeException.hxx"
 #include "Log.hxx"
+#include "Utils.hxx"
 
 using namespace std;
 
@@ -82,6 +86,14 @@ namespace Batch {
 #else
       throw RunTimeException("Can't use SSH protocol (SSH tools were "
                              "not found on the system at compile time).");
+#endif
+    } else if (protocolType == RSYNC) {
+#ifdef HAS_RSYNC
+      static CommunicationProtocolRsync instanceRsync;
+      return instanceRsync;
+#else
+      throw RunTimeException("Can't use RSYNC protocol (RSYNC tools were "
+                             "not found on the system at compile time).");
 #endif
     } else
       throw APIInternalFailureException("Unknown communication protocol.");
@@ -169,7 +181,8 @@ namespace Batch {
 
       // if the argument contains spaces, we surround it with simple quotes (Linux)
       // or double quotes (Windows)
-      if (commandArgs[i].find(' ') != string::npos) {
+      if (commandArgs[i].find(' ') != string::npos &&
+          !Utils::isOption(commandArgs[i])){
         commandStr += string("\"") + commandArgs[i] + "\"";
       } else {
         commandStr += commandArgs[i];