Next Previous Contents

60. stat_is


Parse the st_mode field of a stat structure


Integer_Type stat_is (String_Type type, Integer_Type st_mode}


The stat_is function returns an integer value about the type of file specified by st_mode. Specifically, type must be one of the strings:

     "sock"     (socket)
     "fifo"     (fifo)
     "blk"      (block device)
     "chr"      (character device)
     "reg"      (regular file)
     "lnk"      (link)
     "dir"      (dir)
It returns a non-zero value if st_mode corresponds to type.

The following example illustrates how to use the stat_is function to determine whether or not a file is a directory:

     define is_directory (file)
        variable st;

        st = stat_file (file);
        if (st == NULL) return 0;
        return stat_is ("dir", st.st_mode);
See Also

stat_file, lstat_file

Next Previous Contents