[Python-checkins] python/dist/src/Modules posixmodule.c, 2.335, 2.336

perky@users.sourceforge.net perky at users.sourceforge.net
Thu Jun 2 15:09:32 CEST 2005


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19602/Modules

Modified Files:
	posixmodule.c 
Log Message:
Patch #1212117: Add optional attribute st_flags to os.stat_result
when the member is available on the platform. (Contributed by
Diego Petteno)


Index: posixmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.335
retrieving revision 2.336
diff -u -d -r2.335 -r2.336
--- posixmodule.c	16 May 2005 02:42:21 -0000	2.335
+++ posixmodule.c	2 Jun 2005 13:09:28 -0000	2.336
@@ -674,8 +674,8 @@
   (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 @@
 #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 @@
 #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 @@
 	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);



More information about the Python-checkins mailing list