Mail Archives: djgpp/1998/04/04/12:18:39
I have this sickening feeling that I am missing something really obvious. I
have done the normal things--mail archives, FAQ, docs, sources, fiddling--but I
still don't understand why this doesn't work.
I'm trying to list only subdirectories. Here's the little test program:
#include <stdio.h>
#include <dir.h>
void show_dirs(char *files)
{
/* this is only slightly modified from the docs */
struct ffblk f;
int done = findfirst(files, &f, FA_DIREC);
while (!done)
{
printf("%10u\t%20s\n",
/* show attrib for debugging. 16 corresponds to a subdir. */
f.ff_attrib,
f.ff_name);
done = findnext(&f);
}
putchar('\n');
return;
}
int main(void)
{
show_dirs("*");
return 0;
}
It looks like it should find and show subdirectories, but it shows all the
files, including the ones whose ff_attrib != FA_DIREC. Confusion. One weird
thing is that using -1 as the attrib makes the program not output anything.
--Ed (Myknees)
- Raw text -