diff Python/import.c @ 64594:84217b2d8c0c

Fix Issue #9752: MSVC compiler warning due to undefined function (Patch by Jon Anglin)
author Daniel Stutzbach <daniel@stutzbachenterprises.com>
date Thu, 09 Sep 2010 21:18:04 +0000
parents 725231211273
children 252895d49157
line wrap: on
line diff
--- a/Python/import.c	Thu Sep 09 21:17:58 2010 +0000
+++ b/Python/import.c	Thu Sep 09 21:18:04 2010 +0000
@@ -25,6 +25,8 @@
 #ifdef MS_WINDOWS
 /* for stat.st_mode */
 typedef unsigned short mode_t;
+/* for _mkdir */
+#include <direct.h>
 #endif
 
 
@@ -1134,9 +1136,6 @@
     time_t mtime = srcstat->st_mtime;
 #ifdef MS_WINDOWS   /* since Windows uses different permissions  */
     mode_t mode = srcstat->st_mode & ~S_IEXEC;
-    mode_t dirmode = srcstat->st_mode | S_IEXEC; /* XXX Is this correct
-                                                    for Windows?
-                                                    2010-04-07 BAW */
 #else
     mode_t mode = srcstat->st_mode & ~S_IXUSR & ~S_IXGRP & ~S_IXOTH;
     mode_t dirmode = (srcstat->st_mode |
@@ -1156,8 +1155,12 @@
     }
     saved = *dirpath;
     *dirpath = '\0';
-    /* XXX call os.mkdir() or maybe CreateDirectoryA() on Windows? */
+
+#ifdef MS_WINDOWS
+    if (_mkdir(cpathname) < 0 && errno != EEXIST) {
+#else
     if (mkdir(cpathname, dirmode) < 0 && errno != EEXIST) {
+#endif
         *dirpath = saved;
         if (Py_VerboseFlag)
             PySys_WriteStderr(