/ Published in: C
This simple code return the name of files
Expand |
Embed | Plain Text
#include <stdio.h> #include <dirent.h> #include <sys/types.h> #include <unistd.h> #include <sys/stat.h> #include <time.h> //coded by cobra90nj int main(int argc, char **argv) { struct dirent *drs; struct stat buf; DIR *dir; if (argc == 1) { dir = opendir("."); } else { dir = opendir(argv[1]); } while ((drs = readdir(dir)) != NULL) { stat(drs->d_name, &buf); printf("\033[0;20;31m Nome File: %s\n Ultima modifica: %s\n Dimensione file: %d B \n", drs->d_name, ctime(&(buf.st_mtime)), buf.st_size); } closedir(dir); }
You need to login to post a comment.
