Mercurial > cpython-lru_cache-weakref
diff Python/fileutils.c @ 65164:1f3919af8a53
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
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Thu, 07 Oct 2010 22:09:40 +0000 |
| parents | 7879a8ec7f79 |
| children | 2147cc152227 |
line wrap: on
line diff
--- a/Python/fileutils.c Thu Oct 07 21:55:44 2010 +0000 +++ b/Python/fileutils.c Thu Oct 07 22:09:40 2010 +0000 @@ -1,4 +1,7 @@ #include "Python.h" +#ifdef MS_WINDOWS +# include <windows.h> +#endif #ifdef HAVE_STAT @@ -183,10 +186,6 @@ 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 @@ -194,9 +193,10 @@ 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); @@ -207,7 +207,6 @@ err = stat(fname, buf); PyMem_Free(fname); return err; -#endif } #endif
