Salome HOME
Compilation under Windows: add missing header
[modules/kernel.git] / src / Launcher / Launcher_Job_YACSFile.cxx
index 286cc5e4af9782d23cc8e89db2cf0994cbe8e663..6d8b57cbe4da22daf1ca66691c47f4a46bb01dd2 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2019  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2009-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -21,6 +21,7 @@
 //
 #include "Launcher_Job_YACSFile.hxx"
 #include <sstream>
+#include <sys/stat.h>
 
 const char Launcher::Job_YACSFile::TYPE_NAME[] = "yacs_file";
 
@@ -42,7 +43,12 @@ Launcher::Job_YACSFile::setJobFile(const std::string & job_file)
 void
 Launcher::Job_YACSFile::addJobTypeSpecificScript(std::ofstream & launch_script_stream)
 {
-  launch_script_stream << _resource_definition.AppliPath << "/salome shell -p \"$appli_port\" -- driver -k\"$appli_port\" " << _job_file_name_complete;
+  struct stat statbuf;
+  if(stat(getenv("APPLI"), &statbuf) ==0 &&  S_ISREG(statbuf.st_mode))
+      // case of a salome launcher file
+      launch_script_stream << _resource_definition.AppliPath << " shell -p \"$appli_port\" -- driver -k\"$appli_port\" " << _job_file_name_complete;
+  else
+      launch_script_stream << _resource_definition.AppliPath << "/salome shell -p \"$appli_port\" -- driver -k\"$appli_port\" " << _job_file_name_complete;
   if (_dumpState > 0)
     launch_script_stream << " --dump=" << _dumpState;
   if(! _yacsDriverOptions.empty())