Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* stat.h interface | 1 /* stat.h interface |
2 * | 2 * |
3 * The module defines all S_IF*, S_I*, UF_*, SF_* and ST_* constants to | 3 * The module defines all S_IF*, S_I*, UF_*, SF_* and ST_* constants to |
4 * sensible default values as well as defines S_IS*() macros in order to keep | 4 * sensible default values as well as defines S_IS*() macros in order to keep |
5 * backward compatibility with the old stat.py module. | 5 * backward compatibility with the old stat.py module. |
6 * | 6 * |
7 * New constants and macros such as S_IFDOOR / S_ISDOOR() are always defined | 7 * New constants and macros such as S_IFDOOR / S_ISDOOR() are always defined |
8 * as int 0. | 8 * as int 0. |
9 * | 9 * |
10 * NOTE: POSIX only defines the values of the S_I* permission bits. | 10 * NOTE: POSIX only defines the values of the S_I* permission bits. |
11 * | 11 * |
12 */ | 12 */ |
13 | 13 |
14 #define PY_SSIZE_T_CLEAN | 14 #define PY_SSIZE_T_CLEAN |
15 #include "Python.h" | 15 #include "Python.h" |
16 | 16 |
17 #ifdef __cplusplus | 17 #ifdef __cplusplus |
18 extern "C" { | 18 extern "C" { |
19 #endif | 19 #endif |
20 | 20 |
21 #ifdef HAVE_SYS_TYPES_H | 21 #ifdef HAVE_SYS_TYPES_H |
22 #include <sys/types.h> | 22 #include <sys/types.h> |
23 #endif /* HAVE_SYS_TYPES_H */ | 23 #endif /* HAVE_SYS_TYPES_H */ |
24 | 24 |
25 #ifdef HAVE_SYS_STAT_H | 25 #ifdef HAVE_SYS_STAT_H |
26 #include <sys/stat.h> | 26 #include <sys/stat.h> |
27 #endif /* HAVE_SYS_STAT_H */ | 27 #endif /* HAVE_SYS_STAT_H */ |
28 | 28 |
29 #ifdef MS_WINDOWS | 29 #ifdef MS_WINDOWS |
30 #include <windows.h> | |
30 typedef unsigned short mode_t; | 31 typedef unsigned short mode_t; |
31 #endif | 32 #endif |
32 | 33 |
33 /* From Python's stat.py */ | 34 /* From Python's stat.py */ |
34 #ifndef S_IMODE | 35 #ifndef S_IMODE |
35 # define S_IMODE 07777 | 36 # define S_IMODE 07777 |
36 #endif | 37 #endif |
37 | 38 |
38 /* S_IFXXX constants (file types) | 39 /* S_IFXXX constants (file types) |
39 * | 40 * |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 "ST_MODE\n\ | 467 "ST_MODE\n\ |
467 ST_INO\n\ | 468 ST_INO\n\ |
468 ST_DEV\n\ | 469 ST_DEV\n\ |
469 ST_NLINK\n\ | 470 ST_NLINK\n\ |
470 ST_UID\n\ | 471 ST_UID\n\ |
471 ST_GID\n\ | 472 ST_GID\n\ |
472 ST_SIZE\n\ | 473 ST_SIZE\n\ |
473 ST_ATIME\n\ | 474 ST_ATIME\n\ |
474 ST_MTIME\n\ | 475 ST_MTIME\n\ |
475 ST_CTIME\n\ | 476 ST_CTIME\n\ |
477 \n" | |
478 | |
479 "FILE_ATTRIBUTE_*: Windows file attribute constants (only present on Windows)\n\ | |
476 "); | 480 "); |
477 | 481 |
478 | 482 |
479 static struct PyModuleDef statmodule = { | 483 static struct PyModuleDef statmodule = { |
480 PyModuleDef_HEAD_INIT, | 484 PyModuleDef_HEAD_INIT, |
481 "_stat", | 485 "_stat", |
482 module_doc, | 486 module_doc, |
483 -1, | 487 -1, |
484 stat_methods, | 488 stat_methods, |
485 NULL, | 489 NULL, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 if (PyModule_AddIntConstant(m, "ST_MODE", 0)) return NULL; | 551 if (PyModule_AddIntConstant(m, "ST_MODE", 0)) return NULL; |
548 if (PyModule_AddIntConstant(m, "ST_INO", 1)) return NULL; | 552 if (PyModule_AddIntConstant(m, "ST_INO", 1)) return NULL; |
549 if (PyModule_AddIntConstant(m, "ST_DEV", 2)) return NULL; | 553 if (PyModule_AddIntConstant(m, "ST_DEV", 2)) return NULL; |
550 if (PyModule_AddIntConstant(m, "ST_NLINK", 3)) return NULL; | 554 if (PyModule_AddIntConstant(m, "ST_NLINK", 3)) return NULL; |
551 if (PyModule_AddIntConstant(m, "ST_UID", 4)) return NULL; | 555 if (PyModule_AddIntConstant(m, "ST_UID", 4)) return NULL; |
552 if (PyModule_AddIntConstant(m, "ST_GID", 5)) return NULL; | 556 if (PyModule_AddIntConstant(m, "ST_GID", 5)) return NULL; |
553 if (PyModule_AddIntConstant(m, "ST_SIZE", 6)) return NULL; | 557 if (PyModule_AddIntConstant(m, "ST_SIZE", 6)) return NULL; |
554 if (PyModule_AddIntConstant(m, "ST_ATIME", 7)) return NULL; | 558 if (PyModule_AddIntConstant(m, "ST_ATIME", 7)) return NULL; |
555 if (PyModule_AddIntConstant(m, "ST_MTIME", 8)) return NULL; | 559 if (PyModule_AddIntConstant(m, "ST_MTIME", 8)) return NULL; |
556 if (PyModule_AddIntConstant(m, "ST_CTIME", 9)) return NULL; | 560 if (PyModule_AddIntConstant(m, "ST_CTIME", 9)) return NULL; |
561 | |
562 #ifdef MS_WINDOWS | |
Zach Ware
2014/06/13 15:49:28
Even though these constants are really only useful
haypo
2014/06/13 16:00:20
The purpose of the _stat module is to only provide
Zach Ware
2014/06/13 22:56:16
This is just the opposite of the situation for the
| |
563 // For some reason FILE_ATTRIBUTE_INTEGRITY_STREAM and | |
Zach Ware
2014/06/13 15:49:28
PEP 7 bans C++ style comments.
| |
564 // FILE_ATTRIBUTE_NO_SCRUB_DATA are not present in VC2010, | |
Zach Ware
2014/06/13 15:49:28
As the API doc says, those two are related to ReFS
haypo
2014/06/13 16:00:20
If the constant is only available on new Visual St
| |
565 // so define them manually | |
566 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_ARCHIVE)) return NULL; | |
567 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_COMPRESSED)) return NULL; | |
568 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_DEVICE)) return NULL; | |
569 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_DIRECTORY)) return NULL; | |
570 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_ENCRYPTED)) return NULL; | |
571 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_HIDDEN)) return NULL; | |
572 if (PyModule_AddIntConstant(m, "FILE_ATTRIBUTE_INTEGRITY_STREAM", 0x8000)) r eturn NULL; | |
573 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_NORMAL)) return NULL; | |
574 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)) return NULL ; | |
575 if (PyModule_AddIntConstant(m, "FILE_ATTRIBUTE_NO_SCRUB_DATA", 0x20000)) ret urn NULL; | |
576 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_OFFLINE)) return NULL; | |
577 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_READONLY)) return NULL; | |
578 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_REPARSE_POINT)) return NULL; | |
579 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_SPARSE_FILE)) return NULL; | |
580 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_SYSTEM)) return NULL; | |
581 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_TEMPORARY)) return NULL; | |
582 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_VIRTUAL)) return NULL; | |
583 #endif | |
557 | 584 |
558 return m; | 585 return m; |
559 } | 586 } |
560 | 587 |
561 #ifdef __cplusplus | 588 #ifdef __cplusplus |
562 } | 589 } |
563 #endif | 590 #endif |
OLD | NEW |