-// Copyright (C) 2006-2013 CEA/DEN, EDF R&D
+// 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.
+// 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
#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 WNT
+#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"
DEBTRACE("execute");
char dir[]="yacsXXXXXX";
// add a lock around mkdtemp (seems not thread safe)
- MUTEX.lock();
-#ifdef WNT
- char mdir [512+1];
- GetTempPath(MAX_PATH+1, mdir);
- CreateDirectory(mdir, NULL);
+ {
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&MUTEX);
+#ifdef WIN32
+#ifdef UNICODE
+wchar_t mdir[512 + 1];
#else
- char* mdir=mkdtemp(dir);
+ char mdir[512 + 1];
#endif
- MUTEX.unlock();
- if(mdir==NULL)
- {
- perror("mkdtemp failed");
- std::cerr << "Problem in mkdtemp " << dir << " " << mdir << std::endl;
- throw Exception("Execution problem in mkdtemp");
- }
+ 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());