]> granicus.if.org Git - python/commitdiff
Issue #23753: Move _Py_wstat() from Python/fileutils.c to Modules/getpath.c
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 24 Mar 2015 11:16:28 +0000 (12:16 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 24 Mar 2015 11:16:28 +0000 (12:16 +0100)
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.

Include/fileutils.h
Modules/getpath.c
Python/fileutils.c

index 577ad88736ea5cbcd1c3a5bd42d4b3efc958fcbf..93a9297c87ab940784b513ec3d2fbdbd995d9ac0 100644 (file)
@@ -15,10 +15,6 @@ PyAPI_FUNC(char*) Py_EncodeLocale(
     const wchar_t *text,
     size_t *error_pos);
 
-PyAPI_FUNC(int) _Py_wstat(
-    const wchar_t* path,
-    struct stat *buf);
-
 #ifndef Py_LIMITED_API
 
 #ifdef MS_WINDOWS
index 3564d72afb8071481deb856cd543232673d108b9..429bef348997952dec89f69642d407d83b39a5ca 100644 (file)
@@ -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)
 {
index 63c25714923b853d53817bf31aa95ff63e97fe68..e6d3154490fef0e53e056c5ed6ca87c0338a689d 100644 (file)
@@ -520,23 +520,6 @@ Py_EncodeLocale(const wchar_t *text, size_t *error_pos)
 }
 
 
-/* Get file status. Encode the path to the locale encoding. */
-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;
-}
-
-
 #ifdef MS_WINDOWS
 static __int64 secs_between_epochs = 11644473600; /* Seconds between 1.1.1601 and 1.1.1970 */