3 #include <dirent.h> /* directory */
4 #include <stdlib.h> /* C standard library */
6 /* computation function for DirScan */
7 int do_ls(struct dirent * direntry);
9 int main(int argc, char *argv[])
12 if ((argc - optind) != 1) { /* There must be remaing parameters */
13 printf("Wrong number of arguments %d\n", argc - optind);
16 DirScan(argv[1], do_ls);
20 * Routine to print file name and size inside DirScan
22 int do_ls(struct dirent * direntry)
26 stat(direntry->d_name, &data); /* get stat data */
27 printf("File: %s \t size: %d\n", direntry->d_name, data.st_size);