diff options
author | Hye-Shik Chang <hyeshik@gmail.com> | 2005-06-02 13:09:30 (GMT) |
---|---|---|
committer | Hye-Shik Chang <hyeshik@gmail.com> | 2005-06-02 13:09:30 (GMT) |
commit | 5f937a7b8b1ba766ffada44d27f84ab1a43dc980 (patch) | |
tree | 753bffb3e2ccd767ca7805d7dd00b9da0f4eab6d /Modules/posixmodule.c | |
parent | f36947032f4e99b2c55fc25fa36a1960c4423cbb (diff) | |
download | cpython-5f937a7b8b1ba766ffada44d27f84ab1a43dc980.zip cpython-5f937a7b8b1ba766ffada44d27f84ab1a43dc980.tar.gz cpython-5f937a7b8b1ba766ffada44d27f84ab1a43dc980.tar.bz2 |
Patch #1212117: Add optional attribute st_flags to os.stat_result
when the member is available on the platform. (Contributed by
Diego Petteno)
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 79d5e71..e4a0200 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -674,8 +674,8 @@ This object may be accessed either as a tuple of\n\ (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)\n\ or via the attributes st_mode, st_ino, st_dev, st_nlink, st_uid, and so on.\n\ \n\ -Posix/windows: If your platform supports st_blksize, st_blocks, or st_rdev,\n\ -they are available as attributes only.\n\ +Posix/windows: If your platform supports st_blksize, st_blocks, st_rdev,\n\ +or st_flags, they are available as attributes only.\n\ \n\ See os.stat for more information."); @@ -703,6 +703,9 @@ static PyStructSequence_Field stat_result_fields[] = { #ifdef HAVE_STRUCT_STAT_ST_RDEV {"st_rdev", "device type (if inode device)"}, #endif +#ifdef HAVE_STRUCT_STAT_ST_FLAGS + {"st_flags", "user defined flags for file"}, +#endif {0} }; @@ -724,6 +727,12 @@ static PyStructSequence_Field stat_result_fields[] = { #define ST_RDEV_IDX ST_BLOCKS_IDX #endif +#ifdef HAVE_STRUCT_STAT_ST_FLAGS +#define ST_FLAGS_IDX (ST_RDEV_IDX+1) +#else +#define ST_FLAGS_IDX ST_RDEV_IDX +#endif + static PyStructSequence_Desc stat_result_desc = { "stat_result", /* name */ stat_result__doc__, /* doc */ @@ -887,6 +896,10 @@ _pystat_fromstructstat(STRUCT_STAT st) PyStructSequence_SET_ITEM(v, ST_RDEV_IDX, PyInt_FromLong((long)st.st_rdev)); #endif +#ifdef HAVE_STRUCT_STAT_ST_FLAGS + PyStructSequence_SET_ITEM(v, ST_FLAGS_IDX, + PyInt_FromLong((long)st.st_flags)); +#endif if (PyErr_Occurred()) { Py_DECREF(v); |