Mail Archives: djgpp/1999/08/01/02:07:07
chongkong AT my-deja DOT com wrote:
>
> is there any sample code to do a recursive process for file of a
> certain extension from a parent directory and its sub-directory?
>
> i thinking of using system("dir > tmpfilename")
> and then checking tmpfilename.
>
> or is there a much better way
>
> but i really have no clue on how to go on and search all the sub-
> directory
How about the (also unportable, unfortunately):
glob_t g;
int i;
glob(".../*.ext", 0, NULL, &g);
for (i = 0; i < g.gl_pathc; i++)
process_file(g.gl_pathv[i]);
Error handling is left as an exercise.
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -