Next Previous Contents

59. stat_file

Synopsis

Get information about a file

Usage

Struct_Type stat_file (String_Type file)

Description

The stat_file function returns information about file through the use of the system stat call. If the stat call fails, the function returns NULL and sets errno accordingly. If it is successful, it returns a stat structure with the following integer fields:

    st_dev
    st_ino
    st_mode
    st_nlink
    st_uid
    st_gid
    st_rdev
    st_size
    st_atime
    st_mtime
    st_ctime
See the man page for stat for a discussion of these fields.
Example

The following example shows how the stat_file function may be used to get the size of a file:

     define file_size (file)
     {
        variable st;
        st = stat_file(file);
        if (st == NULL) verror ("Unable to stat %s", file);
        return st.st_size;
     }
See Also

lstat_file, stat_is


Next Previous Contents