Revision: 71857 http://sourceforge.net/p/brlcad/code/71857 Author: starseeker Date: 2018-09-26 20:16:13 +0000 (Wed, 26 Sep 2018) Log Message: ----------- Fix Windows compilation
Modified Paths: -------------- brlcad/trunk/src/other/libnetpbm/libpm.cxx Modified: brlcad/trunk/src/other/libnetpbm/libpm.cxx =================================================================== --- brlcad/trunk/src/other/libnetpbm/libpm.cxx 2018-09-26 19:51:42 UTC (rev 71856) +++ brlcad/trunk/src/other/libnetpbm/libpm.cxx 2018-09-26 20:16:13 UTC (rev 71857) @@ -63,7 +63,9 @@ #include <string> +#include <io.h> + extern "C" { #include <stdio.h> #include <stdarg.h> @@ -791,21 +793,32 @@ int fd; unsigned int attempts; bool gotFile; - bool error; + bool error = FALSE; - for (attempts = 0, gotFile = FALSE, error = FALSE; - !gotFile && !error && attempts < 100; - ++attempts) { + for (attempts = 0, gotFile = FALSE, error = FALSE; + !gotFile && !error && attempts < 100; + ++attempts) { - char * rc; - rc = mktemp(filenameBuffer); + char * rc; +#ifdef WIN32 + int err = _mktemp_s(filenameBuffer, strlen(filenameBuffer) + 9 + 1); + if (err != 0) { + rc == NULL; + error = TRUE; + } +#else + rc = mktemp(filenameBuffer); + if (rc == NULL) error = TRUE; +#endif - if (rc == NULL) - error = TRUE; - else { + if (!error) { int rc; +#ifdef WIN32 + rc = _open(filenameBuffer, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); +#else rc = open(filenameBuffer, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); +#endif if (rc == 0) { fd = rc; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits