1. Armin Rigo
  2. cpython-withatomic

Commits

Victor Stinner  committed 1f3919a

Fix fileutils for Windows

* Don't define _Py_wstat() on Windows, Windows has its own _wstat() function
with a different API (the stat buffer has another type)
* Include windows.h

  • Participants
  • Parent commits 7879a8e
  • Branches default

Comments (0)

Files changed (2)

File Include/fileutils.h

View file
 PyAPI_FUNC(char*) _Py_wchar2char(
     const wchar_t *text);
 
-#if defined(MS_WINDOWS) || defined(HAVE_STAT)
+#if defined(HAVE_STAT) && !defined(MS_WINDOWS)
 PyAPI_FUNC(int) _Py_wstat(
     const wchar_t* path,
     struct stat *buf);

File Python/fileutils.c

View file
 #include "Python.h"
+#ifdef MS_WINDOWS
+#  include <windows.h>
+#endif
 
 #ifdef HAVE_STAT
 
     return result;
 }
 
-#if defined(MS_WINDOWS) || defined(HAVE_STAT)
-int
-_Py_wstat(const wchar_t* path, struct stat *buf)
-{
 /* In principle, this should use HAVE__WSTAT, and _wstat
    should be detected by autoconf. However, no current
    POSIX system provides that function, so testing for
    Not sure whether the MS_WINDOWS guards are necessary:
    perhaps for cygwin/mingw builds?
 */
-#ifdef MS_WINDOWS
-    return _wstat(path, buf);
-#else
+#if defined(HAVE_STAT) && !defined(MS_WINDOWS)
+int
+_Py_wstat(const wchar_t* path, struct stat *buf)
+{
     int err;
     char *fname;
     fname = _Py_wchar2char(path);
     err = stat(fname, buf);
     PyMem_Free(fname);
     return err;
-#endif
 }
 #endif