home *** CD-ROM | disk | FTP | other *** search
- /*
- * ISFILE.C: Return in ERROR_LEVEL the number of files present in the
- * directory given as argument (0 if empty)
- *
- * Public Domain by Francois Bergeon (CIS: 73377,3170), September 1990
- *
- * Compile with Turbo-C
- */
- #include <stdio.h>
- #include <dos.h>
- #include <dir.h>
-
- void main(argc, argv)
- int argc;
- char *argv[];
- {
- struct ffblk buf;
- char dir[128];
- int n = 0;
-
- if (argc != 2)
- {
- printf("Argument is a directory name\n");
- exit(-1);
- }
- strcpy(dir, argv[1]);
- strcat(dir, "\\*.*");
- if (findfirst(dir, &buf, 0) == 0)
- do
- ++n;
- while (findnext(&buf) >= 0);
- exit(n);
- }