Commits

Jason R. Coombs committed ce303f7

Moved directory detection into an isdir function.

  • Participants
  • Parent commits 714b8f9
  • Branches 3.2

Comments (0)

Files changed (1)

     {0, 0}
 };
 
+#ifdef HAVE_STAT
+int isdir(char *path) {
+    struct stat statbuf;
+    return stat(path, &statbuf) == 0 && S_ISDIR(statbuf.st_mode);
+}
+#else
+int isdir(char *path) {
+    return 0;
+}
+#endif
 
 /* Initialize things */
 
 
         /* Check for package import (buf holds a directory name,
            and there's an __init__ module in that directory */
-#ifdef HAVE_STAT
-        if (stat(buf, &statbuf) == 0 &&         /* it exists */
-            S_ISDIR(statbuf.st_mode) &&         /* it's a directory */
+        if (isdir(buf) &&                       /* it's an existing directory */
             case_ok(buf, len, namelen, name)) { /* case matches */
             if (find_init_module(buf)) { /* and has __init__.py */
                 PyMem_FREE(name);
                     goto error_exit;
             }
         }
-#endif
 #if defined(PYOS_OS2)
         /* take a snapshot of the module spec for restoration
          * after the 8 character DLL hackery