]> granicus.if.org Git - python/commitdiff
Define S_IFMT and S_IFLNK in pyport.h so posixmodule.c can use named constants instead
authorChristian Heimes <christian@cheimes.de>
Sun, 23 Jun 2013 21:56:05 +0000 (23:56 +0200)
committerChristian Heimes <christian@cheimes.de>
Sun, 23 Jun 2013 21:56:05 +0000 (23:56 +0200)
of arbitrary looking numbers.

Include/pyport.h
Modules/posixmodule.c

index 4b9c238b9f33974e6482e4351af87ce5abb5f9a7..f16cce9c496b871ffb29e51e4b9b4f337bc0b633 100644 (file)
@@ -393,9 +393,15 @@ typedef size_t Py_uhash_t;
 #include <stat.h>
 #endif
 
-#if defined(PYCC_VACPP)
+#ifndef S_IFMT
 /* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */
-#define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG)
+#define S_IFMT 0170000
+#endif
+
+#ifndef S_IFLNK
+/* Windows doesn't define S_IFLNK but posixmodule.c maps
+ * IO_REPARSE_TAG_SYMLINK to S_IFLNK */
+#  define S_IFLNK 0120000
 #endif
 
 #ifndef S_ISREG
@@ -410,11 +416,6 @@ typedef size_t Py_uhash_t;
 #define S_ISCHR(x) (((x) & S_IFMT) == S_IFCHR)
 #endif
 
-#ifndef S_ISBLK
-#define S_ISBLK(x) (((x) & S_IFMT) == S_IFBLK)
-#endif
-
-
 #ifdef __cplusplus
 /* Move this down here since some C++ #include's don't like to be included
    inside an extern "C" */
index 738bf0a472546d55ae45f3b380701c5d0ad4cdcb..baad29918b87c243f2f90c8812c5cfe7f9815163 100644 (file)
@@ -1405,9 +1405,9 @@ attribute_data_to_stat(BY_HANDLE_FILE_INFORMATION *info, ULONG reparse_tag, stru
     result->st_ino = (((__int64)info->nFileIndexHigh)<<32) + info->nFileIndexLow;
     if (reparse_tag == IO_REPARSE_TAG_SYMLINK) {
         /* first clear the S_IFMT bits */
-        result->st_mode ^= (result->st_mode & 0170000);
+        result->st_mode ^= (result->st_mode & S_IFMT);
         /* now set the bits that make this a symlink */
-        result->st_mode |= 0120000;
+        result->st_mode |= S_IFLNK;
     }
 
     return 0;