Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>stat() get file-status information on named file</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
stat()                   Get File-Status Information on Named File

 #include   <sys\types.h>
 #include   <sys\stat.h>

 int          stat(pathname,buffer);
 char         *pathname;                 Path name of existing file
 struct stat  *buffer;                   Pointer to struct receiving results

    stat() gets and stores information about the file or directory
    specified by 'pathname'.  The information is stored in the structure
    pointed to by 'buffer'.  The 'stat' structure (defined in
    <sys\stat.h>) has the following fields:

            st_mode     Bit mask giving information about the
                        open file's mode.  S_IFDIR bit is set if 'pathname'
                        refers to a directory.  S_IFREG is set if 'pathname'
                        refers to an ordinary file.  Read/write permission
                        bits set according to the file's permission mode;
                        execute bits set using the file-name extension.

            st_dev      Drive number of the disk containing the file.

            st_rdev     Same as 'st_dev'.

            st_nlink    Always set to the constant 1.

            st_size     Size of the file in bytes.

            st_atime    Time of the most recent modification of the file.
            st_mtime    Same as 'st_atime'.
            st_ctime    Same as 'st_atime' and 'st_mtime'.

    Returns:    Zero if the file-status information has been successfully
                retrieved. A value of -1 indicates a failure to get the
                information.  On errer, 'errno' is set to ENOENT,
                indicating the file name or path name could not be found.

      Notes:    If 'pathname' refers to a device, the size and time
                fields of the 'stat' structure are not meaningful.

                The 'stat' structure contains three additional fields
                that hold values that are not meaningful under MS-DOS.

See Also: fstat() access() chmod() filelength()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson