c967fe3c8ce25cbc5af81b809b6ab73716f0f150 hiram Fri Jan 14 15:05:35 2011 -0800 initial contents diff --git src/utils/fileExists/fileExists.c src/utils/fileExists/fileExists.c new file mode 100644 index 0000000..cc8e3f3 --- /dev/null +++ src/utils/fileExists/fileExists.c @@ -0,0 +1,56 @@ +/* fileExists - exercise the fileExists function in src/lib/common.c. */ +#include "common.h" +#include "linefile.h" +#include "hash.h" +#include "options.h" + +static char const rcsid[] = "$Id: newProg.c,v 1.30 2010/03/24 21:18:33 hiram Exp $"; + +void usage() +/* Explain usage and exit. */ +{ +errAbort( + "fileExists - exercise the fileExists function in src/lib/common.c\n" + "usage:\n" + " fileExists fileName\n" + "options:\n" + " -testFile=fileName\n\n" + "Verify fileName exists with kent lib function: fileExists(fileName)" + ); +} + +static struct optionSpec options[] = { + {"testFile", OPTION_STRING}, + {NULL, 0}, +}; + +static void doFileExists(char *XXX) +/* fileExists - exercise the fileExists function in src/lib/common.c. */ +{ +char *testFile = optionVal("testFile", NULL); +if (testFile) + { + if (fileExists(testFile)) + printf(" TRUE - file exists: '%s'\n", testFile); + else + printf("FALSE - file does not exist: '%s'\n", testFile); + } +else + errAbort("ERROR: testFile argument specifies NULL ?"); +} + +int main(int argc, char *argv[]) +/* Process command line. */ +{ +optionInit(&argc, argv, options); +if (argc != 1) + usage(); +if (optionExists("testFile")) + doFileExists(argv[1]); +else + { + fprintf(stderr, "ERROR: missing required argument: -testFile=fileName\n"); + usage(); + } +return 0; +}