home *** CD-ROM | disk | FTP | other *** search
- /* try.c try the dir_retrieve() and dir_free routines.
- * get a directory listing, print it and the file count.
- *
- * (c) Copyright 1988 Aspen Scientific
- * All Rights Reserved.
- */
-
- #include "dirret.h"
-
- int
- main(argc, argv)
- int argc;
- char **argv;
- {
- register int i;
- struct dir_retrieve_t *dir;
- char *try;
- int dir_entries;
-
- /* use either the command line argument,
- * or the default - the current dir (".").
- */
- if (argc == 1)
- try = ".";
- else
- try = argv[1];
-
- dir = dir_retrieve( try, &dir_entries );
-
- if (dir == (struct dir_retrieve_t *)0) {
-
- /* print error with errno string */
- perror("dir_retrieve");
- exit(2);
- }
-
- for (i=0; i < dir_entries; ++i)
- printf("%s%c\n", dir[i].name, (dir[i].subdir ? '/':'\0'));
-
- printf("\t%d File(s)\n", dir_entries);
-
- dir_free( dir );
-
- exit(0);
- }
-