#include #include #include #include int main(int argc, char *argv[]) { char *lex_path; DIR *path; struct dirent *dent; extern int errno; if(argc == 1) lex_path = "./"; else if(argc == 2) lex_path = argv[1]; else { printf("inappropriate number of args.\n"); return 1; } if(!(path = opendir(path))) { if(errno == EACCES) printf("improper permissions to read dir.\n"); else if(errno == ENOENT) printf("given directory does not exist.\n"); else if(errno == ENFILE) printf("we're out of fd's.\n"); else if(errno == ENOTDIR) printf("argument is not a directory.\n"); else printf("an unspecified error occurred.\n"); return errno; } if((dent = readdir(path)) != NULL) { if( } return 0; }