summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-01-15 14:20:08 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-01-15 14:20:08 (GMT)
commit01a80fc3245afba8ccfde2d2a2c8d6fa3c0a321a (patch)
tree399eb4db48546703391bce7dd7b4aaaa7d9408bd
parent333348d70b9cb6dab149ff57bdf9345cdee9e0ef (diff)
downloaduscxml-01a80fc3245afba8ccfde2d2a2c8d6fa3c0a321a.zip
uscxml-01a80fc3245afba8ccfde2d2a2c8d6fa3c0a321a.tar.gz
uscxml-01a80fc3245afba8ccfde2d2a2c8d6fa3c0a321a.tar.bz2
Bug fixes and tests for URL class
-rw-r--r--src/uscxml/URL.cpp16
-rw-r--r--test/src/test-url.cpp1
2 files changed, 15 insertions, 2 deletions
diff --git a/src/uscxml/URL.cpp b/src/uscxml/URL.cpp
index 59fca34..ca3e8f7 100644
--- a/src/uscxml/URL.cpp
+++ b/src/uscxml/URL.cpp
@@ -20,7 +20,11 @@
#include "uscxml/config.h"
#include <stdio.h> /* defines FILENAME_MAX */
-#ifdef WIN32
+#ifdef _WIN32
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <io.h>
#include <direct.h>
#define getcwd _getcwd
#else
@@ -88,13 +92,21 @@ const std::string URLImpl::asLocalFile(const std::string& suffix, bool reload) {
memcpy(writePtr, suffix.c_str(), suffix.length()); writePtr += suffix.length();
tmpl[writePtr - tmpl] = 0;
+#ifdef _WIN32
+ _mktemp_s(tmpl, strlen(tmpl) + 1);
+ int fd = _open(tmpl, _O_CREAT, _S_IREAD | _S_IWRITE);
+#else
int fd = mkstemps(tmpl, suffix.length());
+#endif
if (fd < 0) {
LOG(ERROR) << "mkstemp: " << strerror(errno) << std::endl;
return "";
}
+#ifdef WIN32
+ _close(fd);
+#else
close(fd);
-
+#endif
_localFile = std::string(tmpl);
std::ofstream file(tmpl, std::ios_base::out);
diff --git a/test/src/test-url.cpp b/test/src/test-url.cpp
index e7fbae4..239ff3c 100644
--- a/test/src/test-url.cpp
+++ b/test/src/test-url.cpp
@@ -1,6 +1,7 @@
#include "uscxml/URL.h"
#include <assert.h>
#include <boost/algorithm/string.hpp>
+#include <iostream>
using namespace uscxml;
using namespace boost;