mirror of https://github.com/python/cpython
Patch #1212117: Add optional attribute st_flags to os.stat_result
when the member is available on the platform. (Contributed by Diego Petteno)
This commit is contained in:
parent
f36947032f
commit
5f937a7b8b
|
@ -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},
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -489,6 +489,9 @@
|
|||
/* 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
|
||||
|
||||
|
|
Loading…
Reference in New Issue