check_function_exists(ftime HAVE_FTIME)
check_function_exists(timegm HAVE_TIMEGM)
check_function_exists(rint HAVE_RINT)
-
+check_function_exists(mkdtemp HAVE_MKDTEMP)
if(HAVE_UNISTD_H)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH})
//
// $Id$
+#ifdef HAVE_CONFIG_H
+# include <simgear_config.h>
+#endif
#include <simgear/misc/sg_dir.hxx>
Dir Dir::tempDir(const std::string& templ)
{
+#ifdef HAVE_MKDTEMP
+ char buf[1024];
+ char* tempPath = ::getenv("TMPDIR");
+ if (!tempPath) {
+ tempPath = "/tmp/";
+ }
+ // Mac OS-X / BSD manual says any number of 'X's, but GLibc manual
+ // says exactly six, so that's what I'm going with
+ ::snprintf(buf, 1024, "%s%s-XXXXXX", tempPath, templ.c_str());
+ if (!mkdtemp(buf)) {
+ SG_LOG(SG_IO, SG_WARN, "mkdtemp failed:" << strerror(errno));
+ return Dir();
+ }
+
+ return Dir(SGPath(buf));
+#else
SGPath p(tempnam(0, templ.c_str()));
Dir t(p);
if (!t.create(0700)) {
}
return t;
+#endif
}
PathList Dir::children(int types, const std::string& nameFilter) const
#cmakedefine HAVE_TIMEGM
#cmakedefine HAVE_ISNAN
#cmakedefine HAVE_WINDOWS_H
+#cmakedefine HAVE_MKDTEMP
#cmakedefine HAVE_SVN_CLIENT_H
#cmakedefine HAVE_LIBSVN_CLIENT_1