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

Unified Diff: Modules/posixmodule.c

Issue 21719: Returning Windows file attribute information via os.stat()
Patch Set: Created 5 years, 11 months ago
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_stat.py ('k') | Modules/_stat.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Modules/posixmodule.c Thu Jun 12 19:41:30 2014 -0400
+++ b/Modules/posixmodule.c Sat Jun 14 11:09:50 2014 -0400
@@ -1417,6 +1417,7 @@
Therefore, we implement our own stat, based on the Win32 API directly.
*/
#define HAVE_STAT_NSEC 1
+#define HAVE_STRUCT_STAT_ST_FILE_ATTRIBUTES 1
struct win32_stat{
unsigned long st_dev;
@@ -1433,6 +1434,7 @@
int st_mtime_nsec;
time_t st_ctime;
int st_ctime_nsec;
+ unsigned long st_file_attributes;
};
static __int64 secs_between_epochs = 11644473600; /* Seconds between 1.1.1601 and 1.1.1970 */
@@ -1497,6 +1499,7 @@
/* now set the bits that make this a symlink */
result->st_mode |= S_IFLNK;
}
+ result->st_file_attributes = info->dwFileAttributes;
return 0;
}
@@ -1961,6 +1964,9 @@
#ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME
{"st_birthtime", "time of creation"},
#endif
+#ifdef HAVE_STRUCT_STAT_ST_FILE_ATTRIBUTES
+ {"st_file_attributes", "Windows file attribute bits"},
+#endif
{0}
};
@@ -2000,6 +2006,12 @@
#define ST_BIRTHTIME_IDX ST_GEN_IDX
#endif
+#ifdef HAVE_STRUCT_STAT_ST_FILE_ATTRIBUTES
+#define ST_FILE_ATTRIBUTES_IDX (ST_BIRTHTIME_IDX+1)
+#else
+#define ST_FILE_ATTRIBUTES_IDX ST_BIRTHTIME_IDX
+#endif
+
static PyStructSequence_Desc stat_result_desc = {
"stat_result", /* name */
stat_result__doc__, /* doc */
@@ -2267,6 +2279,10 @@
PyStructSequence_SET_ITEM(v, ST_FLAGS_IDX,
PyLong_FromLong((long)st->st_flags));
#endif
+#ifdef HAVE_STRUCT_STAT_ST_FILE_ATTRIBUTES
+ PyStructSequence_SET_ITEM(v, ST_FILE_ATTRIBUTES_IDX,
+ PyLong_FromUnsignedLong(st->st_file_attributes));
+#endif
if (PyErr_Occurred()) {
Py_DECREF(v);
« no previous file with comments | « Lib/test/test_stat.py ('k') | Modules/_stat.c » ('j') | no next file with comments »

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