src/platform_windows.cpp
changeset 130 507895068f83
parent 107 fbef1c59da96
child 140 7abc23dbfdfe
     1.1 --- a/src/platform_windows.cpp	Wed Mar 25 15:35:08 2015 +0100
     1.2 +++ b/src/platform_windows.cpp	Thu Mar 26 15:30:21 2015 +0100
     1.3 @@ -14,6 +14,8 @@
     1.4  #include <string>
     1.5  #include <stdexcept>
     1.6  #include "platform_windows.h"
     1.7 +#include <fcntl.h>
     1.8 +#include <sys\stat.h>
     1.9  
    1.10  #ifndef WC_ERR_INVALID_CHARS
    1.11  #define WC_ERR_INVALID_CHARS      0x00000080  // error for invalid chars
    1.12 @@ -200,12 +202,12 @@
    1.13          e = rand_s(&r);
    1.14      } while (e);
    1.15  
    1.16 -    return (long) (r & ((1<<31)-1));
    1.17 +    return (long) (r & ((1U<<31)-1));
    1.18  }
    1.19  
    1.20  char *strndup(const char *s1, size_t n)
    1.21  {
    1.22 -    char *str = calloc(n + 1, 1);
    1.23 +    char *str = (char *) calloc(n + 1, 1);
    1.24      if (str == NULL)
    1.25          return NULL;
    1.26  
    1.27 @@ -213,5 +215,12 @@
    1.28      return str;
    1.29  }
    1.30  
    1.31 +int mkstemp(char *templ)
    1.32 +{
    1.33 +    char *pathname = _mktemp(templ);
    1.34 +    if (errno)
    1.35 +        return -1;
    1.36 +    return _open(pathname, _O_RDWR | _O_CREAT | _O_EXCL, _S_IREAD | _S_IWRITE);
    1.37 +}
    1.38 +
    1.39  } // "C"
    1.40 -