I'm currently working on a command line app(for windows) than seaches from the current directory down recursively and garhers information on files. Currently, the only information is the file location. Is really simple as I'm not a C expert. Ultimately the purpose of the program is to search the directories, see which files are html and php, open them and extract some info such as keywords and description and put them in a file.
Again, at this point the only info I'm interested in gathering is the address of the file, eg. c:\test\foo.html, since I figure once I'm able to do that I can expand on it.
I've been able to do it, but in a way that I know is not very efficient. Basically, the program searches recursively, if the program finds an html file it writes the location of that file to another file called files_list.txt. Obiously this is not good because if we have 1000 html files the program would have to open files_list.txt, write to the file, and close the file 1000 times.
it works but it's ugly.
What I figure what I could do is make a multi-dimensional array. Add the locations to the array. When The program finishes, the array could be written to file just once. This would cut work time significantly. Since in windows xp the MAX_PATH variable (the maximum size of a file location) is 260 chars, if I wanted to make an array that could hold 100,000 file locations I would do something like:
This is bad cause the program would need 260 megs! to hold 100,000 file locations. And imagine if I wanted to put other info such as description. It is unlikely that I'm gonna have 100,000 pages, but I would like the program to be able to handle it.
Another solution would be to create a variable only when the program finds a file, if I could do something like this(I don't know if it's possible, but I looked for it and can't find information)
// create multi-dimensional array with on entry
// if the program finds a file then do something like
this would expand the array by one and put "c:\test\foo.hmtl" at that location
I program in php and things like this are possible but I don't think they are possible in C.
My question is, does anyone has something equivalent to this. I don't want to create fixed size arrays.