Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <unistd.h>
- int main(void){
- struct stat sb;
- stat("/tmp", &sb);
- switch (sb.st_mode & S_IFMT) { /* & binary AND */
- case S_IFBLK:
- printf("block device node\n");break;
- case S_IFCHR:
- printf("character device node\n");break;
- case S_IFDIR:
- printf("directory\n");break;
- case S_IFIFO:
- printf("FIFO\n");break;
- case S_IFLNK:
- printf("symbolic link\n");break;
- case S_IFREG:
- printf("regular file\n");break;
- case S_IFSOCK:
- printf("socket\n");break;
- default:
- printf("unknown\n");
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement