diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-01-15 14:20:08 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-01-15 14:20:08 (GMT) |
commit | 01a80fc3245afba8ccfde2d2a2c8d6fa3c0a321a (patch) | |
tree | 399eb4db48546703391bce7dd7b4aaaa7d9408bd /src/uscxml/URL.cpp | |
parent | 333348d70b9cb6dab149ff57bdf9345cdee9e0ef (diff) | |
download | uscxml-01a80fc3245afba8ccfde2d2a2c8d6fa3c0a321a.zip uscxml-01a80fc3245afba8ccfde2d2a2c8d6fa3c0a321a.tar.gz uscxml-01a80fc3245afba8ccfde2d2a2c8d6fa3c0a321a.tar.bz2 |
Bug fixes and tests for URL class
Diffstat (limited to 'src/uscxml/URL.cpp')
-rw-r--r-- | src/uscxml/URL.cpp | 16 |
1 files changed, 14 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); |