"David Jacques" <Da***********@ ccrs.nrcan.gc.c a> wrote:
# I am trying to get a list of all files of a certain extension type on disk
# to
# do some processing in a loop. The code needs to be portable to UNIX, so
# I need to use plain c functionality. Does anyone know of a way to do this ?
# Any URLs, code snippets, etc ?
If the implementation includes a working system() function and the command
interpretter it calls provides this functionality, then you can start with
something like (for unix)
char command[REALLYBIGINTEGE R];
sprintf(command ,"/usr/bin/ls '%s' >.listing",dire ctoryToBeListed );
system(command) ;
FILE *listing = fopen(".listing ","r");
char line[REALLYBIGINTEGE R];
while (fgets(line,lis ting)) {
...
}
fclose(listing) ;
system("/usr/bin/rm .listing");
modulo all the usual caveats about error checks and quote escapes, etc. I think
WIndows allows something similar but with command like 'DIR' or something.
--
SM Ryan
http://www.rawbw.com/~wyrmwif/
What kind of convenience store do you run here?