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
This commit is contained in:
Victor Stinner 2010-10-07 22:09:40 +00:00
parent e7c8083bf1
commit b306d7594f
2 changed files with 8 additions and 9 deletions

View file

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

View file

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