X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FCore%2FBatch_CommunicationProtocol.cxx;h=8a3ef6ada2b5c7591028c54e8208c5305b1ba94a;hb=f9cfa27307e650551fd1f69d616cdec5f9ff2efd;hp=656c9fdc854d20396ed1792ec2e253abb25045ad;hpb=c7322a67a33c799c93e04638945c085b94fce2bd;p=tools%2Flibbatch.git diff --git a/src/Core/Batch_CommunicationProtocol.cxx b/src/Core/Batch_CommunicationProtocol.cxx index 656c9fd..8a3ef6a 100644 --- a/src/Core/Batch_CommunicationProtocol.cxx +++ b/src/Core/Batch_CommunicationProtocol.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2009 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -26,14 +26,22 @@ * Author : Renaud BARATE - EDF R&D */ +#include #include +#include #include #include "Batch_CommunicationProtocol.hxx" -#include "Batch_CommunicationProtocolRSH.hxx" -#include "Batch_CommunicationProtocolSH.hxx" -#include "Batch_CommunicationProtocolSSH.hxx" +#ifdef HAS_RSH + #include "Batch_CommunicationProtocolRSH.hxx" +#endif +#ifdef HAS_SH + #include "Batch_CommunicationProtocolSH.hxx" +#endif +#ifdef HAS_SSH + #include "Batch_CommunicationProtocolSSH.hxx" +#endif #include "Batch_APIInternalFailureException.hxx" #include "Batch_RunTimeException.hxx" @@ -48,13 +56,13 @@ namespace Batch { const CommunicationProtocol & CommunicationProtocol::getInstance(CommunicationProtocolType protocolType) { if (protocolType == SH) { - #ifdef HAS_SH - static CommunicationProtocolSH instanceSH; - return instanceSH; - #else - throw RunTimeException("Can't use SH protocol (SH tools were " - "not found on the system at compile time)."); - #endif +#ifdef HAS_SH + static CommunicationProtocolSH instanceSH; + return instanceSH; +#else + throw RunTimeException("Can't use SH protocol (SH tools were " + "not found on the system at compile time)."); +#endif } else if (protocolType == RSH) { #ifdef HAS_RSH static CommunicationProtocolRSH instanceRSH; @@ -102,6 +110,11 @@ namespace Batch { return string("rm ") + path; } + string CommunicationProtocol::getMakeDirectorySubCommand(const string & path) const + { + return string("mkdir -p ") + path; + } + int CommunicationProtocol::removeFile(const std::string & path, const std::string & host, const std::string & user) const @@ -112,6 +125,16 @@ namespace Batch { return status; } + int CommunicationProtocol::makeDirectory(const std::string & path, + const std::string & host, + const std::string & user) const + { + string command = getExecCommand(getMakeDirectorySubCommand(path), host, user); + cout << command.c_str() << endl; + int status = system(command.c_str()); + return status; + } + string CommunicationProtocol::commandStringFromArgs(const vector & commandArgs) const { string commandStr; @@ -125,7 +148,8 @@ namespace Batch { for (unsigned int i=0 ; i