<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE TIP SYSTEM "http://www.tcl.tk/cgi-bin/tct/tip/tipxml.dtd">
<!-- Converted at Thu May 17 04:09:40 GMT 2012 -->
<!-- TIP AutoGenerator - written by Donal K. Fellows -->

<TIP number='316'>
<header><title>Portable Access Functions for Stat Buffers</title><author address="mailto:donal.k.fellows@manchester.ac.uk">Donal K. Fellows</author><status type='project' state='final' tclversion="8.6" vote='after'>$Revision: 1.4 $</status><history></history><created day='2' month='may' year='2008' /></header>
<abstract>Tcl exposes the definition of the <emph style="italic">struct stat</emph> type to users of its C API, but this can vary between builds. This TIP proposes a set of portable functions for reading (portable) fields out of those structures so that code does not need to match the API version when reading the fields (the most common case by far).</abstract>
<body><section title="Rationale">
<para>The <emph style="italic">struct stat</emph> type used by Tcl can be one of many different types depending on compile-time options (as a consequence of 64-bit filesystem support). Tcl conceals these details by wrapping the type as a <emph style="italic">Tcl_StatBuf</emph> and providing a way to allocate these independently of compiler configuration. However, there is no way to access the contents of the field without binding to a particular type i.e. particular compile time configuration of Tcl (and not necessarily the extension code using the API!) This TIP proposes a set of simple access functions to conceal these details and enable the portable read-only use of the <emph style="italic">Tcl_StatBuf</emph> type.</para>
</section>
<section title="Proposed Change">
<para>This TIP proposes that the following functions will be defined. Each will take a pointer to a <emph style="italic">Tcl_StatBuf</emph> as its only argument, and will return the contents of the field indicated below.</para>
<describe><item.d name='Tcl_GetFSDeviceFromStat'><para>Returns the <emph style="italic">st_dev</emph> field as an unsigned integer.</para></item.d><item.d name='Tcl_GetFSInodeFromStat'><para>Returns the <emph style="italic">st_ino</emph> field as an unsigned integer.</para></item.d><item.d name='Tcl_GetModeFromStat'><para>Returns the <emph style="italic">st_mode</emph> field as an unsigned integer.</para></item.d><item.d name='Tcl_GetLinkCountFromStat'><para>Returns the <emph style="italic">st_nlink</emph> field as an integer.</para></item.d><item.d name='Tcl_GetUserIdFromStat'><para>Returns the <emph style="italic">st_uid</emph> field as an integer.</para></item.d><item.d name='Tcl_GetGroupIdFromStat'><para>Returns the <emph style="italic">st_gid</emph> field as an integer.</para></item.d><item.d name='Tcl_GetDeviceTypeFromStat'><para>Returns the <emph style="italic">st_rdev</emph> field as an integer.</para></item.d><item.d name='Tcl_GetAccessTimeFromStat'><para>Returns the <emph style="italic">st_atime</emph> field as a wide integer.</para></item.d><item.d name='Tcl_GetModificationTimeFromStat'><para>Returns the <emph style="italic">st_mtime</emph> field as a wide integer.</para></item.d><item.d name='Tcl_GetChangeTimeFromStat'><para>Returns the <emph style="italic">st_ctime</emph> field as a wide integer.</para></item.d><item.d name='Tcl_GetSizeFromStat'><para>Returns the <emph style="italic">st_size</emph> field as an unsigned wide integer.</para></item.d><item.d name='Tcl_GetBlocksFromStat'><para>Returns the <emph style="italic">st_blocks</emph> field as an unsigned wide integer.</para></item.d><item.d name='Tcl_GetBlockSizeFromStat'><para>Returns the <emph style="italic">st_blksize</emph> field as an unsigned integer.</para></item.d></describe>
<para>Some platforms may support other fields; these are not universal and are hence not portable.</para>
</section>
<section title="Copyright">
<para>This document has been placed in the public domain.</para>
</section>
</body></TIP>

