Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(52)

Side by Side Diff: Modules/_stat.c

Issue 21719: Returning Windows file attribute information via os.stat()
Patch Set: Created 5 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Modules/posixmodule.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
32
33 /* FILE_ATTRIBUTE_INTEGRITY_STREAM and FILE_ATTRIBUTE_NO_SCRUB_DATA
34 are not present in VC2010, so define them manually */
35 #ifndef FILE_ATTRIBUTE_INTEGRITY_STREAM
36 # define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x8000
37 #endif
38 #ifndef FILE_ATTRIBUTE_NO_SCRUB_DATA
39 # define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x20000
40 #endif
41
31 #endif 42 #endif
32 43
33 /* From Python's stat.py */ 44 /* From Python's stat.py */
34 #ifndef S_IMODE 45 #ifndef S_IMODE
35 # define S_IMODE 07777 46 # define S_IMODE 07777
36 #endif 47 #endif
37 48
38 /* S_IFXXX constants (file types) 49 /* S_IFXXX constants (file types)
39 * 50 *
40 * Only the names are defined by POSIX but not their value. All common file 51 * Only the names are defined by POSIX but not their value. All common file
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 "ST_MODE\n\ 477 "ST_MODE\n\
467 ST_INO\n\ 478 ST_INO\n\
468 ST_DEV\n\ 479 ST_DEV\n\
469 ST_NLINK\n\ 480 ST_NLINK\n\
470 ST_UID\n\ 481 ST_UID\n\
471 ST_GID\n\ 482 ST_GID\n\
472 ST_SIZE\n\ 483 ST_SIZE\n\
473 ST_ATIME\n\ 484 ST_ATIME\n\
474 ST_MTIME\n\ 485 ST_MTIME\n\
475 ST_CTIME\n\ 486 ST_CTIME\n\
487 \n"
488
489 "FILE_ATTRIBUTE_*: Windows file attribute constants (only present on Windows)\n\
476 "); 490 ");
477 491
478 492
479 static struct PyModuleDef statmodule = { 493 static struct PyModuleDef statmodule = {
480 PyModuleDef_HEAD_INIT, 494 PyModuleDef_HEAD_INIT,
481 "_stat", 495 "_stat",
482 module_doc, 496 module_doc,
483 -1, 497 -1,
484 stat_methods, 498 stat_methods,
485 NULL, 499 NULL,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 if (PyModule_AddIntConstant(m, "ST_MODE", 0)) return NULL; 561 if (PyModule_AddIntConstant(m, "ST_MODE", 0)) return NULL;
548 if (PyModule_AddIntConstant(m, "ST_INO", 1)) return NULL; 562 if (PyModule_AddIntConstant(m, "ST_INO", 1)) return NULL;
549 if (PyModule_AddIntConstant(m, "ST_DEV", 2)) return NULL; 563 if (PyModule_AddIntConstant(m, "ST_DEV", 2)) return NULL;
550 if (PyModule_AddIntConstant(m, "ST_NLINK", 3)) return NULL; 564 if (PyModule_AddIntConstant(m, "ST_NLINK", 3)) return NULL;
551 if (PyModule_AddIntConstant(m, "ST_UID", 4)) return NULL; 565 if (PyModule_AddIntConstant(m, "ST_UID", 4)) return NULL;
552 if (PyModule_AddIntConstant(m, "ST_GID", 5)) return NULL; 566 if (PyModule_AddIntConstant(m, "ST_GID", 5)) return NULL;
553 if (PyModule_AddIntConstant(m, "ST_SIZE", 6)) return NULL; 567 if (PyModule_AddIntConstant(m, "ST_SIZE", 6)) return NULL;
554 if (PyModule_AddIntConstant(m, "ST_ATIME", 7)) return NULL; 568 if (PyModule_AddIntConstant(m, "ST_ATIME", 7)) return NULL;
555 if (PyModule_AddIntConstant(m, "ST_MTIME", 8)) return NULL; 569 if (PyModule_AddIntConstant(m, "ST_MTIME", 8)) return NULL;
556 if (PyModule_AddIntConstant(m, "ST_CTIME", 9)) return NULL; 570 if (PyModule_AddIntConstant(m, "ST_CTIME", 9)) return NULL;
571
572 #ifdef MS_WINDOWS
573 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_ARCHIVE)) return NULL;
574 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_COMPRESSED)) return NULL;
575 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_DEVICE)) return NULL;
576 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_DIRECTORY)) return NULL;
577 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_ENCRYPTED)) return NULL;
578 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_HIDDEN)) return NULL;
579 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_INTEGRITY_STREAM)) return NULL;
580 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_NORMAL)) return NULL;
581 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)) return NULL ;
582 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_NO_SCRUB_DATA)) return NULL;
583 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_OFFLINE)) return NULL;
584 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_READONLY)) return NULL;
585 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_REPARSE_POINT)) return NULL;
586 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_SPARSE_FILE)) return NULL;
587 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_SYSTEM)) return NULL;
588 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_TEMPORARY)) return NULL;
589 if (PyModule_AddIntMacro(m, FILE_ATTRIBUTE_VIRTUAL)) return NULL;
590 #endif
557 591
558 return m; 592 return m;
559 } 593 }
560 594
561 #ifdef __cplusplus 595 #ifdef __cplusplus
562 } 596 }
563 #endif 597 #endif
OLDNEW
« no previous file with comments | « Modules/posixmodule.c ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+