I need to print all possible file attributes in a directory such as file size, type, ect. The code below uses the dirent structure and it doesnt have all the file information, like file size. The d_type returns some integer, but i can find a chart to look up the meaning of those numbers. I am printing the inode and the name of the file. Can i use the inode to get more information about the file with c commands?
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
#include <sys/stat.h>
#include <errno.h>
int main(int ac, char *av[])
{
DIR *d;
struct dirent *dir;
d = opendir("/home/CS/user/unix/Project4/TestDirectory");
if (d) {
while ((dir = readdir(d)) != NULL) {
printf("Name: %s \n", dir->d_name);
printf("- Inode: %lu\n", dir->d_ino);
printf("- reclen: %u\n", dir->d_reclen);
printf("- type: %u\n", dir->d_type);
}
closedir(d);
}
return(0);
}