Хорошей оболочкой для FindFirstFile является dirent.h для Windows (google dirent.h Тони Ронкко)
#define S_ISREG(B) ((B)&_S_IFREG)
#define S_ISDIR(B) ((B)&_S_IFDIR)
static void
scan_dir(DirScan *d, const char *adir, BOOL recurse_dir)
{
DIR *dirfile;
int adir_len = strlen(adir);
if ((dirfile = opendir(adir)) != NULL) {
struct dirent *entry;
char path[MAX_PATH + 1];
char *file;
while ((entry = readdir(dirfile)) != NULL)
{
struct stat buf;
if(!strcmp(".",entry->d_name) || !strcmp("..",entry->d_name))
continue;
sprintf(path,"%s/%.*s", adir, MAX_PATH-2-adir_len, entry->d_name);
if (stat(path,&buf) != 0)
continue;
file = entry->d_name;
if (recurse_dir && S_ISDIR(buf.st_mode) )
scan_dir(d, path, recurse_dir);
else if (match_extension(path) && _access(path, R_OK) == 0) // e.g. match .code
strs_find_add_str(&d->files,&d->n_files,_strdup(path));
}
closedir(dirfile);
}
return;
}