ยปCore Development>Code coverage>Modules/_stat.c

Python code coverage for Modules/_stat.c

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