c - How to display uid, size and file's type? -


i'm using gcc 32bit compiler. used stat() function, not giving information type of file. there function or way find these?

i believe looking st_mode member of struct stat.

from stat(2) manpage:

     status information word st_mode has following bits:   #define s_ifmt 0170000           /* type of file */  #define        s_ififo  0010000  /* named pipe (fifo) */  #define        s_ifchr  0020000  /* character special */  #define        s_ifdir  0040000  /* directory */  #define        s_ifblk  0060000  /* block special */  #define        s_ifreg  0100000  /* regular */  #define        s_iflnk  0120000  /* symbolic link */  #define        s_ifsock 0140000  /* socket */  #define        s_ifwht  0160000  /* whiteout */  #define s_isuid 0004000  /* set user id on execution */  #define s_isgid 0002000  /* set group id on execution */  #define s_isvtx 0001000  /* save swapped text after use */  #define s_irusr 0000400  /* read permission, owner */  #define s_iwusr 0000200  /* write permission, owner */  #define s_ixusr 0000100  /* execute/search permission, owner */ 

sys/stat.h provides following defines testing file type. use them passing value of st_mode parameter:

#define s_isblk(m)      (((m) & s_ifmt) == s_ifblk)     /* block special */ #define s_ischr(m)      (((m) & s_ifmt) == s_ifchr)     /* char special */ #define s_isdir(m)      (((m) & s_ifmt) == s_ifdir)     /* directory */ #define s_isfifo(m)     (((m) & s_ifmt) == s_ififo)     /* fifo or socket */ #define s_isreg(m)      (((m) & s_ifmt) == s_ifreg)     /* regular file */ #define s_islnk(m)      (((m) & s_ifmt) == s_iflnk)     /* symbolic link */ #define s_issock(m)     (((m) & s_ifmt) == s_ifsock)    /* socket */ 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -