Return to Snippet

Revision: 9633
at November 15, 2008 09:45 by cobra90nj


Initial Code
#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);

}

Initial URL


Initial Description
This simple code return the name of files

Initial Title
Operation  on directory

Initial Tags
file, directory

Initial Language
C