Changeset 13968


Ignore:
Timestamp:
Feb 4, 2013, 9:07:24 PM (8 years ago)
Author:
jordan
Message:

(libT) add rb07's win32 implementation of tr_mkstemp()

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/variant-benc.c

    r13687 r13968  
    1414#include <ctype.h> /* isdigit() */
    1515#include <errno.h>
    16 #include <stdlib.h> /* strtoul(), strtod(), realloc(), qsort(), mkstemp() */
     16#include <stdlib.h> /* strtoul() */
    1717#include <string.h> /* strlen(), memchr() */
    1818
  • trunk/libtransmission/variant.c

    r13868 r13968  
    1414#include <errno.h>
    1515#include <stdio.h> /* rename() */
    16 #include <stdlib.h> /* strtoul(), strtod(), realloc(), qsort(), mkstemp() */
     16#include <stdlib.h> /* strtod(), realloc(), qsort(), mkstemp() */
    1717#include <string.h>
    1818
    1919#ifdef WIN32 /* tr_mkstemp() */
    2020 #include <fcntl.h>
    21  #define _S_IREAD 256
    22  #define _S_IWRITE 128
     21 #include <share.h>
     22 #include <sys/stat.h>
    2323#endif
    2424
     
    11341134{
    11351135#ifdef WIN32
     1136
     1137  const int n = strlen (template) + 1;
    11361138  const int flags = O_RDWR | O_BINARY | O_CREAT | O_EXCL | _O_SHORT_LIVED;
    11371139  const mode_t mode = _S_IREAD | _S_IWRITE;
    1138   mktemp (template);
    1139   return open (template, flags, mode);
     1140  wchar_t templateUTF16[n];
     1141
     1142  if (MultiByteToWideChar(CP_UTF8, 0, template, -1, templateUTF16, n))
     1143    {
     1144      _wmktemp(templateUTF16);
     1145      WideCharToMultiByte(CP_UTF8, 0, templateUTF16, -1, template, n, NULL, NULL);
     1146      return _wopen(chkFilename(templateUTF16), flags, mode);
     1147    }
     1148  errno = EINVAL;
     1149  return -1;
     1150
    11401151#else
     1152
    11411153  return mkstemp (template);
     1154
    11421155#endif
    11431156}
Note: See TracChangeset for help on using the changeset viewer.