]> granicus.if.org Git - python/commitdiff
Patch #1212117: Add optional attribute st_flags to os.stat_result
authorHye-Shik Chang <hyeshik@gmail.com>
Thu, 2 Jun 2005 13:09:30 +0000 (13:09 +0000)
committerHye-Shik Chang <hyeshik@gmail.com>
Thu, 2 Jun 2005 13:09:30 +0000 (13:09 +0000)
when the member is available on the platform. (Contributed by
Diego Petteno)

Doc/lib/libos.tex
Misc/NEWS
Modules/posixmodule.c
configure
configure.in
pyconfig.h.in

index d38e9be09695974510235641e6a9f495d5683d06..2d0327f55d8e643ec3ac580076cc918547717511 100644 (file)
@@ -966,6 +966,7 @@ also be available:
 \member{st_blocks} (number of blocks allocated for file),
 \member{st_blksize} (filesystem blocksize),
 \member{st_rdev} (type of device if an inode device).
+\member{st_flags} (user defined flags for file).
 
 On Mac OS systems, the following attributes may also be available:
 \member{st_rsize},
index 0ea2b54e428f7ce8ede997d6c44085e9144b74e0..196d7629ce7b07d887d2687e86a1729073628676 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -88,6 +88,9 @@ Core and builtins
 Extension Modules
 -----------------
 
+- Patch #1212117: os.stat().st_flags is now accessible as a attribute
+  if available on the platform.
+
 - Patch #1103951: Expose O_SHLOCK and O_EXLOCK in the posix module if
   available on the platform.
 
index 79d5e718c966ef15e9b9d3dd7ee2dcb4357cdf33..e4a0200f046628be1908b8c5df19a81874610be0 100644 (file)
@@ -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.");
 
@@ -702,6 +702,9 @@ static PyStructSequence_Field stat_result_fields[] = {
 #endif
 #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);
index 0984980481a05152584b20e7b9c7414c644b73ad..2e45be0a7649a71d243388a4e5a83c34d0350f48 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.483 .
+# From configure.in Revision: 1.484 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59 for python 2.5.
 #
@@ -16412,6 +16412,116 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+fi
+
+echo "$as_me:$LINENO: checking for struct stat.st_flags" >&5
+echo $ECHO_N "checking for struct stat.st_flags... $ECHO_C" >&6
+if test "${ac_cv_member_struct_stat_st_flags+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static struct stat ac_aggr;
+if (ac_aggr.st_flags)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_member_struct_stat_st_flags=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static struct stat ac_aggr;
+if (sizeof ac_aggr.st_flags)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_member_struct_stat_st_flags=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_member_struct_stat_st_flags=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_member_struct_stat_st_flags" >&5
+echo "${ECHO_T}$ac_cv_member_struct_stat_st_flags" >&6
+if test $ac_cv_member_struct_stat_st_flags = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_STAT_ST_FLAGS 1
+_ACEOF
+
+
 fi
 
 echo "$as_me:$LINENO: checking for struct stat.st_blocks" >&5
index 6f292f93f6e2b0ed2faba3d9270bd77dca31a067..101fd441382a5797587c569b98128babb47f6f94 100644 (file)
@@ -2421,6 +2421,7 @@ AC_STRUCT_TM
 AC_STRUCT_TIMEZONE
 AC_CHECK_MEMBERS([struct stat.st_rdev])
 AC_CHECK_MEMBERS([struct stat.st_blksize])
+AC_CHECK_MEMBERS([struct stat.st_flags])
 AC_STRUCT_ST_BLOCKS
 
 AC_MSG_CHECKING(for time.h that defines altzone)
index 1ce039746407db0ff9039f694c34d5ebc5cef080..a60e4dad84ba618d437fc68010518c9bdf6708b9 100644 (file)
 /* Define to 1 if `st_blocks' is member of `struct stat'. */
 #undef HAVE_STRUCT_STAT_ST_BLOCKS
 
+/* Define to 1 if `st_flags' is member of `struct stat'. */
+#undef HAVE_STRUCT_STAT_ST_FLAGS
+
 /* Define to 1 if `st_rdev' is member of `struct stat'. */
 #undef HAVE_STRUCT_STAT_ST_RDEV