C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
_fstat, _stat
 Summary Example                         Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
     The _fstat and _stat functions obtain information about an open
     file and store the information in the structure pointed to by
     <buffer>. The _fstat function specifies the file with a file
     handle and provides information about files and devices, but not
     directories. The _stat function specifies the file, which can
     include a path, and provides information about files but not
     drives or directories.
 
     The structure, whose type _stat is defined in SYS\STAT.H,
     contains the following fields:
 
     Field        Value
 
     st_atime     Time of last access of file.
 
     st_ctime     Time of creation of file.
 
     st_dev       For both _fstat and _stat, either the drive number of
                  the disk containing the file. For _fstat only,
                  <handle> in the case of a device (same as st_rdev).
 
     st_mode      Bit mask for file-mode information. The _S_IFDIR
                  bit is set if <pathname> specifies a directory; the
                  _S_IFREG bit is set if <pathname> specifies an
                  ordinary file. User read/write bits are set
                  according to the file's permission mode; user
                  execute bits are set according to the filename
                  extension.
 
     st_mtime     Time of last modification of file.
 
     st_nlink     Always 1.
 
     st_rdev      Either the drive number of the disk containing the
                  file, or <handle> in the case of a device (same as
                  st_dev).
 
     st_size      Size of the file in bytes.
 
     In the File Allocation Table (FAT) file system supported by DOS,
     the creation and last access times of a file are not kept
     separately. Therefore st_atime, st_ctime, and st_mtime are always
     the same. These fields have different values under UNIX.
 
     Note that if <handle> refers to a device, the size and time fields
     in the _stat structure are not meaningful. Also, as STAT.H uses
     the _dev_t type, which is defined in TYPES.H, you must include
     TYPES.H before STAT.H in your code.
 
     Return Value
 
     The _fstat and _stat functions return the value 0 if the file-
     status information is obtained. A return value of -1 indicates an
     error. In the case of error, _fstat sets errno to EBADF,
     indicating an invalid file handle. In the case of an error with
     _stat, errno is set to ENOENT, indicating that the filename or
     path name cannot be found.
                                    -♦-