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