#include #include #include #ifdef _WIN32 #include #endif void f(char *p, FILE *o) { int l = strlen(".$a"); #ifdef _WIN32 WIN32_FIND_DATA d; HANDLE h = FindFirstFile(p, &d); if (h != INVALID_HANDLE_VALUE) { do { if ((d.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 && d.cFileName[0] != '.') { int bytes = strlen(p) - 3 + strlen(d.cFileName) + 4 + 1; char *buf = (char *)malloc(bytes); if (buf != NULL) { strcpy(buf, p); buf[strlen(buf)-3] = 0; strcat(buf, d.cFileName); strcat(buf, "\\*.*"); f(buf, o); free(buf); } } else if (strlen(d.cFileName) > l && stricmp(d.cFileName + strlen(d.cFileName)-l, ".$a") == 0) { int bytes = strlen(p) - 3 + strlen(d.cFileName) + 1; char *buf = (char *)malloc(bytes + 10); if (buf != NULL) { strcpy(buf, p); buf[strlen(buf)-3] = 0; strcat(buf, d.cFileName); fprintf(o, "%s\n", buf); fprintf(stderr, "%s\n", buf); free(buf); } } } while (FindNextFile(h, &d)); FindClose(h); } #else struct find_t *s = (struct find_t *)_fmalloc(sizeof(struct find_t)); char *buf = (char *)_fmalloc(1024); unsigned r; if (s == NULL || buf == NULL) exit(1); r = _dos_findfirst(p, _A_NORMAL|_A_RDONLY|_A_SUBDIR, s); while (r == 0) { char *N = s->name; if (strcmp(N, ".") == 0 || strcmp(N, "..") == 0) ; else if (s->attrib & _A_SUBDIR) { strcpy(buf, p); buf[strlen(buf)-3] = 0; strcat(buf, N); strcat(buf, "\\*.*"); f(buf, o); } else if (strlen(N) > l && stricmp(N+strlen(N)-l, ".$a") == 0) { strcpy(buf, N); strlwr(buf); fprintf(o, "%s\n", buf); } r = _dos_findnext(s); } _ffree(s); _ffree(buf); #endif } main(int argc, char **argv) { FILE *o = stdout; if (argc > 3) o = fopen(argv[3], "w"); if (o != NULL) f("c:\\*.*", o); exit(0); } // FHd="&Computer" PHd="File extension (no .):" P="EXE" QHd="Where on Disk:" Q="[Local Hard Drives Only]" Cls="Superfind" Hlp="Search selected areas of the computer's disk for files of a particular type and send the list to 3 o'clock output. (C program.)" Lng="C" > End