From: kremlin Date: Thu, 9 Oct 2014 17:36:25 +0000 (-0400) Subject: start hw6 X-Git-Url: https://uglyman.kremlin.cc/gitweb/gitweb.cgi?p=assignments.git;a=commitdiff_plain;h=fb4aa7ce182202eb3c858523789ae822fc93c58b start hw6 --- diff --git a/assgn6/filewatch.c b/assgn6/filewatch.c new file mode 100644 index 0000000..3c0bc67 --- /dev/null +++ b/assgn6/filewatch.c @@ -0,0 +1,52 @@ +#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; +}