annotate Modules/_stat.c @ 86127:a3d09c19bb93

merge with 3.3
author Georg Brandl <georg@python.org>
date Sun, 06 Oct 2013 19:24:00 +0200
parents 75bc0ae02bcd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
84258
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
1 /* stat.h interface
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
2 *
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
3 * The module defines all S_IF*, S_I*, UF_*, SF_* and ST_* constants to
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
4 * sensible default values as well as defines S_IS*() macros in order to keep
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
5 * backward compatibility with the old stat.py module.
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
6 *
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
7 * New constants and macros such as S_IFDOOR / S_ISDOOR() are always defined
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
8 * as int 0.
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
9 *
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
10 * NOTE: POSIX only defines the values of the S_I* permission bits.
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
11 *
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
12 */
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
13
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
14 #define PY_SSIZE_T_CLEAN
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
15 #include "Python.h"
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
16
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
17 #ifdef __cplusplus
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
18 extern "C" {
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
19 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
20
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
21 #ifdef HAVE_SYS_TYPES_H
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
22 #include <sys/types.h>
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
23 #endif /* HAVE_SYS_TYPES_H */
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
24
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
25 #ifdef HAVE_SYS_STAT_H
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
26 #include <sys/stat.h>
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
27 #endif /* HAVE_SYS_STAT_H */
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
28
84265
e5427b0b2bf7 Issue #11016: Try to fix compilaton of the new _stat.c module on Windows
Victor Stinner <victor.stinner@gmail.com>
parents: 84258
diff changeset
29 #ifdef MS_WINDOWS
e5427b0b2bf7 Issue #11016: Try to fix compilaton of the new _stat.c module on Windows
Victor Stinner <victor.stinner@gmail.com>
parents: 84258
diff changeset
30 typedef unsigned short mode_t;
e5427b0b2bf7 Issue #11016: Try to fix compilaton of the new _stat.c module on Windows
Victor Stinner <victor.stinner@gmail.com>
parents: 84258
diff changeset
31 #endif
e5427b0b2bf7 Issue #11016: Try to fix compilaton of the new _stat.c module on Windows
Victor Stinner <victor.stinner@gmail.com>
parents: 84258
diff changeset
32
84258
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
33 /* From Python's stat.py */
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
34 #ifndef S_IMODE
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
35 # define S_IMODE 07777
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
36 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
37
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
38 /* S_IFXXX constants (file types)
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
39 *
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
40 * Only the names are defined by POSIX but not their value. All common file
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
41 * types seems to have the same numeric value on all platforms, though.
84302
75bc0ae02bcd Issue #11016: Don't define macros and constants that are already set by pyport.h
Christian Heimes <christian@cheimes.de>
parents: 84298
diff changeset
42 *
75bc0ae02bcd Issue #11016: Don't define macros and constants that are already set by pyport.h
Christian Heimes <christian@cheimes.de>
parents: 84298
diff changeset
43 * pyport.h guarantees S_IFMT, S_IFDIR, S_IFCHR, S_IFREG and S_IFLNK
84258
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
44 */
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
45
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
46 #ifndef S_IFBLK
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
47 # define S_IFBLK 0060000
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
48 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
49
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
50 #ifndef S_IFIFO
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
51 # define S_IFIFO 0010000
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
52 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
53
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
54 #ifndef S_IFSOCK
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
55 # define S_IFSOCK 0140000
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
56 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
57
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
58 #ifndef S_IFDOOR
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
59 # define S_IFDOOR 0
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
60 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
61
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
62 #ifndef S_IFPORT
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
63 # define S_IFPORT 0
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
64 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
65
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
66 #ifndef S_IFWHT
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
67 # define S_IFWHT 0
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
68 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
69
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
70
84302
75bc0ae02bcd Issue #11016: Don't define macros and constants that are already set by pyport.h
Christian Heimes <christian@cheimes.de>
parents: 84298
diff changeset
71 /* S_ISXXX()
75bc0ae02bcd Issue #11016: Don't define macros and constants that are already set by pyport.h
Christian Heimes <christian@cheimes.de>
parents: 84298
diff changeset
72 * pyport.h defines S_ISDIR(), S_ISREG() and S_ISCHR()
75bc0ae02bcd Issue #11016: Don't define macros and constants that are already set by pyport.h
Christian Heimes <christian@cheimes.de>
parents: 84298
diff changeset
73 */
84258
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
74
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
75 #ifndef S_ISBLK
84296
bc52faaa50e5 Fix a typo in S_ISDIR, S_ISCHR, S_ISBLK and S_ISREG.
Christian Heimes <christian@cheimes.de>
parents: 84265
diff changeset
76 # define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
84258
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
77 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
78
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
79 #ifndef S_ISFIFO
84296
bc52faaa50e5 Fix a typo in S_ISDIR, S_ISCHR, S_ISBLK and S_ISREG.
Christian Heimes <christian@cheimes.de>
parents: 84265
diff changeset
80 # define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
84258
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
81 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
82
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
83 #ifndef S_ISLNK
84296
bc52faaa50e5 Fix a typo in S_ISDIR, S_ISCHR, S_ISBLK and S_ISREG.
Christian Heimes <christian@cheimes.de>
parents: 84265
diff changeset
84 # define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
84258
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
85 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
86
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
87 #ifndef S_ISSOCK
84296
bc52faaa50e5 Fix a typo in S_ISDIR, S_ISCHR, S_ISBLK and S_ISREG.
Christian Heimes <christian@cheimes.de>
parents: 84265
diff changeset
88 # define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
84258
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
89 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
90
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
91 #ifndef S_ISDOOR
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
92 # define S_ISDOOR(mode) 0
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
93 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
94
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
95 #ifndef S_ISPORT
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
96 # define S_ISPORT(mode) 0
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
97 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
98
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
99 #ifndef S_ISWHT
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
100 # define S_ISWHT(mode) 0
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
101 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
102
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
103
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
104 /* S_I* file permission
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
105 *
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
106 * The permission bit value are defined by POSIX standards.
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
107 */
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
108 #ifndef S_ISUID
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
109 # define S_ISUID 04000
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
110 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
111
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
112 #ifndef S_ISGID
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
113 # define S_ISGID 02000
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
114 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
115
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
116 /* what is S_ENFMT? */
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
117 #ifndef S_ENFMT
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
118 # define S_ENFMT S_ISGID
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
119 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
120
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
121 #ifndef S_ISVTX
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
122 # define S_ISVTX 01000
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
123 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
124
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
125 #ifndef S_IREAD
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
126 # define S_IREAD 00400
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
127 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
128
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
129 #ifndef S_IWRITE
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
130 # define S_IWRITE 00200
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
131 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
132
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
133 #ifndef S_IEXEC
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
134 # define S_IEXEC 00100
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
135 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
136
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
137 #ifndef S_IRWXU
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
138 # define S_IRWXU 00700
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
139 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
140
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
141 #ifndef S_IRUSR
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
142 # define S_IRUSR 00400
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
143 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
144
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
145 #ifndef S_IWUSR
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
146 # define S_IWUSR 00200
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
147 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
148
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
149 #ifndef S_IXUSR
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
150 # define S_IXUSR 00100
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
151 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
152
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
153 #ifndef S_IRWXG
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
154 # define S_IRWXG 00070
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
155 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
156
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
157 #ifndef S_IRGRP
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
158 # define S_IRGRP 00040
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
159 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
160
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
161 #ifndef S_IWGRP
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
162 # define S_IWGRP 00020
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
163 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
164
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
165 #ifndef S_IXGRP
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
166 # define S_IXGRP 00010
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
167 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
168
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
169 #ifndef S_IRWXO
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
170 # define S_IRWXO 00007
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
171 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
172
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
173 #ifndef S_IROTH
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
174 # define S_IROTH 00004
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
175 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
176
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
177 #ifndef S_IWOTH
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
178 # define S_IWOTH 00002
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
179 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
180
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
181 #ifndef S_IXOTH
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
182 # define S_IXOTH 00001
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
183 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
184
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
185
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
186 /* Names for file flags */
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
187 #ifndef UF_NODUMP
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
188 # define UF_NODUMP 0x00000001
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
189 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
190
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
191 #ifndef UF_IMMUTABLE
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
192 # define UF_IMMUTABLE 0x00000002
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
193 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
194
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
195 #ifndef UF_APPEND
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
196 # define UF_APPEND 0x00000004
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
197 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
198
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
199 #ifndef UF_OPAQUE
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
200 # define UF_OPAQUE 0x00000008
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
201 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
202
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
203 #ifndef UF_NOUNLINK
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
204 # define UF_NOUNLINK 0x00000010
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
205 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
206
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
207 #ifndef UF_COMPRESSED
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
208 # define UF_COMPRESSED 0x00000020
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
209 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
210
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
211 #ifndef UF_HIDDEN
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
212 # define UF_HIDDEN 0x00008000
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
213 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
214
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
215 #ifndef SF_ARCHIVED
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
216 # define SF_ARCHIVED 0x00010000
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
217 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
218
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
219 #ifndef SF_IMMUTABLE
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
220 # define SF_IMMUTABLE 0x00020000
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
221 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
222
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
223 #ifndef SF_APPEND
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
224 # define SF_APPEND 0x00040000
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
225 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
226
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
227 #ifndef SF_NOUNLINK
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
228 # define SF_NOUNLINK 0x00100000
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
229 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
230
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
231 #ifndef SF_SNAPSHOT
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
232 # define SF_SNAPSHOT 0x00200000
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
233 #endif
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
234
84298
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
235 static mode_t
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
236 _PyLong_AsMode_t(PyObject *op)
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
237 {
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
238 unsigned long value;
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
239 mode_t mode;
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
240
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
241 value = PyLong_AsUnsignedLong(op);
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
242 if ((value == (unsigned long)-1) && PyErr_Occurred())
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
243 return (mode_t)-1;
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
244
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
245 mode = (mode_t)value;
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
246 if ((unsigned long)mode != value) {
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
247 PyErr_SetString(PyExc_OverflowError, "mode out of range");
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
248 return (mode_t)-1;
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
249 }
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
250 return mode;
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
251 }
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
252
84258
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
253
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
254 #define stat_S_ISFUNC(isfunc, doc) \
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
255 static PyObject * \
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
256 stat_ ##isfunc (PyObject *self, PyObject *omode) \
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
257 { \
84298
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
258 mode_t mode = _PyLong_AsMode_t(omode); \
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
259 if ((mode == (mode_t)-1) && PyErr_Occurred()) \
84258
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
260 return NULL; \
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
261 return PyBool_FromLong(isfunc(mode)); \
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
262 } \
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
263 PyDoc_STRVAR(stat_ ## isfunc ## _doc, doc)
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
264
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
265 stat_S_ISFUNC(S_ISDIR,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
266 "S_ISDIR(mode) -> bool\n\n"
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
267 "Return True if mode is from a directory.");
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
268
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
269 stat_S_ISFUNC(S_ISCHR,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
270 "S_ISCHR(mode) -> bool\n\n"
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
271 "Return True if mode is from a character special device file.");
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
272
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
273 stat_S_ISFUNC(S_ISBLK,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
274 "S_ISBLK(mode) -> bool\n\n"
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
275 "Return True if mode is from a block special device file.");
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
276
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
277 stat_S_ISFUNC(S_ISREG,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
278 "S_ISREG(mode) -> bool\n\n"
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
279 "Return True if mode is from a regular file.");
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
280
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
281 stat_S_ISFUNC(S_ISFIFO,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
282 "S_ISFIFO(mode) -> bool\n\n"
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
283 "Return True if mode is from a FIFO (named pipe).");
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
284
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
285 stat_S_ISFUNC(S_ISLNK,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
286 "S_ISLNK(mode) -> bool\n\n"
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
287 "Return True if mode is from a symbolic link.");
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
288
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
289 stat_S_ISFUNC(S_ISSOCK,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
290 "S_ISSOCK(mode) -> bool\n\n"
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
291 "Return True if mode is from a socket.");
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
292
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
293 stat_S_ISFUNC(S_ISDOOR,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
294 "S_ISDOOR(mode) -> bool\n\n"
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
295 "Return True if mode is from a door.");
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
296
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
297 stat_S_ISFUNC(S_ISPORT,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
298 "S_ISPORT(mode) -> bool\n\n"
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
299 "Return True if mode is from an event port.");
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
300
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
301 stat_S_ISFUNC(S_ISWHT,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
302 "S_ISWHT(mode) -> bool\n\n"
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
303 "Return True if mode is from a whiteout.");
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
304
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
305
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
306 PyDoc_STRVAR(stat_S_IMODE_doc,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
307 "Return the portion of the file's mode that can be set by os.chmod().");
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
308
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
309 static PyObject *
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
310 stat_S_IMODE(PyObject *self, PyObject *omode)
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
311 {
84298
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
312 mode_t mode = _PyLong_AsMode_t(omode);
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
313 if ((mode == (mode_t)-1) && PyErr_Occurred())
84258
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
314 return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
315 return PyLong_FromUnsignedLong(mode & S_IMODE);
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
316 }
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
317
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
318
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
319 PyDoc_STRVAR(stat_S_IFMT_doc,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
320 "Return the portion of the file's mode that describes the file type.");
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
321
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
322 static PyObject *
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
323 stat_S_IFMT(PyObject *self, PyObject *omode)
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
324 {
84298
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
325 mode_t mode = _PyLong_AsMode_t(omode);
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
326 if ((mode == (mode_t)-1) && PyErr_Occurred())
84258
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
327 return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
328 return PyLong_FromUnsignedLong(mode & S_IFMT);
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
329 }
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
330
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
331 /* file type chars according to
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
332 http://en.wikibooks.org/wiki/C_Programming/POSIX_Reference/sys/stat.h */
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
333
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
334 static char
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
335 filetype(mode_t mode)
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
336 {
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
337 /* common cases first */
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
338 if (S_ISREG(mode)) return '-';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
339 if (S_ISDIR(mode)) return 'd';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
340 if (S_ISLNK(mode)) return 'l';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
341 /* special files */
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
342 if (S_ISBLK(mode)) return 'b';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
343 if (S_ISCHR(mode)) return 'c';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
344 if (S_ISFIFO(mode)) return 'p';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
345 if (S_ISSOCK(mode)) return 's';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
346 /* non-standard types */
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
347 if (S_ISDOOR(mode)) return 'D';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
348 if (S_ISPORT(mode)) return 'P';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
349 if (S_ISWHT(mode)) return 'w';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
350 /* unknown */
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
351 return '?';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
352 }
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
353
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
354 static void
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
355 fileperm(mode_t mode, char *buf)
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
356 {
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
357 buf[0] = mode & S_IRUSR ? 'r' : '-';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
358 buf[1] = mode & S_IWUSR ? 'w' : '-';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
359 if (mode & S_ISUID) {
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
360 buf[2] = mode & S_IXUSR ? 's' : 'S';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
361 } else {
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
362 buf[2] = mode & S_IXUSR ? 'x' : '-';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
363 }
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
364 buf[3] = mode & S_IRGRP ? 'r' : '-';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
365 buf[4] = mode & S_IWGRP ? 'w' : '-';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
366 if (mode & S_ISGID) {
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
367 buf[5] = mode & S_IXGRP ? 's' : 'S';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
368 } else {
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
369 buf[5] = mode & S_IXGRP ? 'x' : '-';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
370 }
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
371 buf[6] = mode & S_IROTH ? 'r' : '-';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
372 buf[7] = mode & S_IWOTH ? 'w' : '-';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
373 if (mode & S_ISVTX) {
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
374 buf[8] = mode & S_IXOTH ? 't' : 'T';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
375 } else {
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
376 buf[8] = mode & S_IXOTH ? 'x' : '-';
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
377 }
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
378 }
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
379
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
380 PyDoc_STRVAR(stat_filemode_doc,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
381 "Convert a file's mode to a string of the form '-rwxrwxrwx'");
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
382
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
383 static PyObject *
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
384 stat_filemode(PyObject *self, PyObject *omode)
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
385 {
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
386 char buf[10];
84298
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
387 mode_t mode;
84258
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
388
84298
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
389 mode = _PyLong_AsMode_t(omode);
44c8a9d80595 Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
Victor Stinner <victor.stinner@gmail.com>
parents: 84296
diff changeset
390 if ((mode == (mode_t)-1) && PyErr_Occurred())
84258
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
391 return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
392
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
393 buf[0] = filetype(mode);
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
394 fileperm(mode, &buf[1]);
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
395 return PyUnicode_FromStringAndSize(buf, 10);
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
396 }
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
397
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
398
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
399 static PyMethodDef stat_methods[] = {
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
400 {"S_ISDIR", stat_S_ISDIR, METH_O, stat_S_ISDIR_doc},
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
401 {"S_ISCHR", stat_S_ISCHR, METH_O, stat_S_ISCHR_doc},
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
402 {"S_ISBLK", stat_S_ISBLK, METH_O, stat_S_ISBLK_doc},
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
403 {"S_ISREG", stat_S_ISREG, METH_O, stat_S_ISREG_doc},
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
404 {"S_ISFIFO", stat_S_ISFIFO, METH_O, stat_S_ISFIFO_doc},
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
405 {"S_ISLNK", stat_S_ISLNK, METH_O, stat_S_ISLNK_doc},
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
406 {"S_ISSOCK", stat_S_ISSOCK, METH_O, stat_S_ISSOCK_doc},
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
407 {"S_ISDOOR", stat_S_ISDOOR, METH_O, stat_S_ISDOOR_doc},
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
408 {"S_ISPORT", stat_S_ISPORT, METH_O, stat_S_ISPORT_doc},
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
409 {"S_ISWHT", stat_S_ISWHT, METH_O, stat_S_ISWHT_doc},
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
410 {"S_IMODE", stat_S_IMODE, METH_O, stat_S_IMODE_doc},
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
411 {"S_IFMT", stat_S_IFMT, METH_O, stat_S_IFMT_doc},
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
412 {"filemode", stat_filemode, METH_O, stat_filemode_doc},
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
413 {NULL, NULL} /* sentinel */
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
414 };
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
415
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
416
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
417 PyDoc_STRVAR(module_doc,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
418 "S_IFMT_: file type bits\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
419 S_IFDIR: directory\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
420 S_IFCHR: character device\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
421 S_IFBLK: block device\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
422 S_IFREG: regular file\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
423 S_IFIFO: fifo (named pipe)\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
424 S_IFLNK: symbolic link\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
425 S_IFSOCK: socket file\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
426 S_IFDOOR: door\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
427 S_IFPORT: event port\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
428 S_IFWHT: whiteout\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
429 \n"
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
430
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
431 "S_ISUID: set UID bit\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
432 S_ISGID: set GID bit\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
433 S_ENFMT: file locking enforcement\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
434 S_ISVTX: sticky bit\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
435 S_IREAD: Unix V7 synonym for S_IRUSR\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
436 S_IWRITE: Unix V7 synonym for S_IWUSR\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
437 S_IEXEC: Unix V7 synonym for S_IXUSR\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
438 S_IRWXU: mask for owner permissions\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
439 S_IRUSR: read by owner\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
440 S_IWUSR: write by owner\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
441 S_IXUSR: execute by owner\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
442 S_IRWXG: mask for group permissions\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
443 S_IRGRP: read by group\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
444 S_IWGRP: write by group\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
445 S_IXGRP: execute by group\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
446 S_IRWXO: mask for others (not in group) permissions\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
447 S_IROTH: read by others\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
448 S_IWOTH: write by others\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
449 S_IXOTH: execute by others\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
450 \n"
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
451
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
452 "UF_NODUMP: do not dump file\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
453 UF_IMMUTABLE: file may not be changed\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
454 UF_APPEND: file may only be appended to\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
455 UF_OPAQUE: directory is opaque when viewed through a union stack\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
456 UF_NOUNLINK: file may not be renamed or deleted\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
457 UF_COMPRESSED: OS X: file is hfs-compressed\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
458 UF_HIDDEN: OS X: file should not be displayed\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
459 SF_ARCHIVED: file may be archived\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
460 SF_IMMUTABLE: file may not be changed\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
461 SF_APPEND: file may only be appended to\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
462 SF_NOUNLINK: file may not be renamed or deleted\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
463 SF_SNAPSHOT: file is a snapshot file\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
464 \n"
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
465
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
466 "ST_MODE\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
467 ST_INO\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
468 ST_DEV\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
469 ST_NLINK\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
470 ST_UID\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
471 ST_GID\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
472 ST_SIZE\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
473 ST_ATIME\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
474 ST_MTIME\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
475 ST_CTIME\n\
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
476 ");
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
477
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
478
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
479 static struct PyModuleDef statmodule = {
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
480 PyModuleDef_HEAD_INIT,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
481 "_stat",
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
482 module_doc,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
483 -1,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
484 stat_methods,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
485 NULL,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
486 NULL,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
487 NULL,
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
488 NULL
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
489 };
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
490
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
491 PyMODINIT_FUNC
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
492 PyInit__stat(void)
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
493 {
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
494 PyObject *m;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
495 m = PyModule_Create(&statmodule);
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
496 if (m == NULL)
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
497 return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
498
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
499 if (PyModule_AddIntMacro(m, S_IFDIR)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
500 if (PyModule_AddIntMacro(m, S_IFCHR)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
501 if (PyModule_AddIntMacro(m, S_IFBLK)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
502 if (PyModule_AddIntMacro(m, S_IFREG)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
503 if (PyModule_AddIntMacro(m, S_IFIFO)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
504 if (PyModule_AddIntMacro(m, S_IFLNK)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
505 if (PyModule_AddIntMacro(m, S_IFSOCK)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
506 if (PyModule_AddIntMacro(m, S_IFDOOR)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
507 if (PyModule_AddIntMacro(m, S_IFPORT)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
508 if (PyModule_AddIntMacro(m, S_IFWHT)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
509
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
510 if (PyModule_AddIntMacro(m, S_ISUID)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
511 if (PyModule_AddIntMacro(m, S_ISGID)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
512 if (PyModule_AddIntMacro(m, S_ISVTX)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
513 if (PyModule_AddIntMacro(m, S_ENFMT)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
514
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
515 if (PyModule_AddIntMacro(m, S_IREAD)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
516 if (PyModule_AddIntMacro(m, S_IWRITE)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
517 if (PyModule_AddIntMacro(m, S_IEXEC)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
518
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
519 if (PyModule_AddIntMacro(m, S_IRWXU)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
520 if (PyModule_AddIntMacro(m, S_IRUSR)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
521 if (PyModule_AddIntMacro(m, S_IWUSR)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
522 if (PyModule_AddIntMacro(m, S_IXUSR)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
523
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
524 if (PyModule_AddIntMacro(m, S_IRWXG)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
525 if (PyModule_AddIntMacro(m, S_IRGRP)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
526 if (PyModule_AddIntMacro(m, S_IWGRP)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
527 if (PyModule_AddIntMacro(m, S_IXGRP)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
528
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
529 if (PyModule_AddIntMacro(m, S_IRWXO)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
530 if (PyModule_AddIntMacro(m, S_IROTH)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
531 if (PyModule_AddIntMacro(m, S_IWOTH)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
532 if (PyModule_AddIntMacro(m, S_IXOTH)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
533
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
534 if (PyModule_AddIntMacro(m, UF_NODUMP)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
535 if (PyModule_AddIntMacro(m, UF_IMMUTABLE)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
536 if (PyModule_AddIntMacro(m, UF_APPEND)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
537 if (PyModule_AddIntMacro(m, UF_OPAQUE)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
538 if (PyModule_AddIntMacro(m, UF_NOUNLINK)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
539 if (PyModule_AddIntMacro(m, UF_COMPRESSED)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
540 if (PyModule_AddIntMacro(m, UF_HIDDEN)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
541 if (PyModule_AddIntMacro(m, SF_ARCHIVED)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
542 if (PyModule_AddIntMacro(m, SF_IMMUTABLE)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
543 if (PyModule_AddIntMacro(m, SF_APPEND)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
544 if (PyModule_AddIntMacro(m, SF_NOUNLINK)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
545 if (PyModule_AddIntMacro(m, SF_SNAPSHOT)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
546
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
547 if (PyModule_AddIntConstant(m, "ST_MODE", 0)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
548 if (PyModule_AddIntConstant(m, "ST_INO", 1)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
549 if (PyModule_AddIntConstant(m, "ST_DEV", 2)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
550 if (PyModule_AddIntConstant(m, "ST_NLINK", 3)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
551 if (PyModule_AddIntConstant(m, "ST_UID", 4)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
552 if (PyModule_AddIntConstant(m, "ST_GID", 5)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
553 if (PyModule_AddIntConstant(m, "ST_SIZE", 6)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
554 if (PyModule_AddIntConstant(m, "ST_ATIME", 7)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
555 if (PyModule_AddIntConstant(m, "ST_MTIME", 8)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
556 if (PyModule_AddIntConstant(m, "ST_CTIME", 9)) return NULL;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
557
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
558 return m;
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
559 }
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
560
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
561 #ifdef __cplusplus
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
562 }
420f70a22b9d Issue #11016: Add C implementation of the stat module as _stat
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
563 #endif