summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-24 11:16:28 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-03-24 11:16:28 (GMT)
commit91afbb60885d5904dc6cb4d063ae33454507bf71 (patch)
tree88446ccd3150c4e107d0157cdb85a70dbc4de596 /Modules
parent10dc48497e9c79d253bd0861b5f41843a114f146 (diff)
downloadcpython-91afbb60885d5904dc6cb4d063ae33454507bf71.zip
cpython-91afbb60885d5904dc6cb4d063ae33454507bf71.tar.gz
cpython-91afbb60885d5904dc6cb4d063ae33454507bf71.tar.bz2
Issue #23753: Move _Py_wstat() from Python/fileutils.c to Modules/getpath.c
I expected more users of _Py_wstat(), but in practice it's only used by Modules/getpath.c. Move the function because it's not needed on Windows. Windows uses PC/getpathp.c which uses the Win32 API (ex: GetFileAttributesW()) not the POSIX API.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/getpath.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 3564d72..429bef3 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -131,6 +131,23 @@ static wchar_t exec_prefix[MAXPATHLEN+1];
static wchar_t progpath[MAXPATHLEN+1];
static wchar_t *module_search_path = NULL;
+/* Get file status. Encode the path to the locale encoding. */
+
+static int
+_Py_wstat(const wchar_t* path, struct stat *buf)
+{
+ int err;
+ char *fname;
+ fname = Py_EncodeLocale(path, NULL);
+ if (fname == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ err = stat(fname, buf);
+ PyMem_Free(fname);
+ return err;
+}
+
static void
reduce(wchar_t *dir)
{