+// Copyright (C) 2006-2021 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
#include "XMLNode.hxx"
#include "XMLPorts.hxx"
#include "Mutex.hxx"
+#include "TypeCode.hxx"
+#include "AutoLocker.hxx"
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef WIN32
+#include <windows.h>
+#include <io.h>
+#define chmod _chmod
+#endif
+#ifdef __APPLE__
+#include <unistd.h> // for mkdtemp
+#endif
+
//#define _DEVDEBUG_
#include "YacsTrace.hxx"
_script=script;
}
+std::string XmlNode::getScript() const
+{
+ return _script;
+}
+
std::string XmlNode::getKind() const
{
return KIND;
DEBTRACE("execute");
char dir[]="yacsXXXXXX";
// add a lock around mkdtemp (seems not thread safe)
- MUTEX.lock();
- char* mdir=mkdtemp(dir);
- MUTEX.unlock();
- if(mdir==NULL)
- {
- perror("mkdtemp failed");
- std::cerr << "Problem in mkdtemp " << dir << " " << mdir << std::endl;
- throw Exception("Execution problem in mkdtemp");
- }
+ {
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&MUTEX);
+#ifdef WIN32
+#ifdef UNICODE
+wchar_t mdir[512 + 1];
+#else
+ char mdir[512 + 1];
+#endif
+ GetTempPath(MAX_PATH+1, mdir);
+ CreateDirectory(mdir, NULL);
+#else
+ char* mdir=mkdtemp(dir);
+#endif
+ if(mdir==NULL)
+ {
+ perror("mkdtemp failed");
+ std::cerr << "Problem in mkdtemp " << dir << " " << mdir << std::endl;
+ throw Exception("Execution problem in mkdtemp");
+ }
+ }
std::string sdir(dir);
std::string input=sdir+"/input";
std::ofstream f(input.c_str());
run << _ref << "> stdout 2>&1 " << std::endl;
else
run << "../"<<_ref << "> stdout 2>&1 " << std::endl;
- run << "cat stdout" << std::endl;
+ //run << "cat stdout" << std::endl;
run.close();
chmod(call.c_str(),00777);
- int ret=system(call.c_str());
+ std::string call2="/bin/sh "+call;
+ int ret=system(call2.c_str());
if(ret)
{
std::cerr << "Problem: " << ret << std::endl;