"zjffdu" <zj****@gmail.com> wrote:
Anyone know how to get the files in one directory?
Yes, I know a bunch of ways. Since I don't know what operating
system(s) you're using, I can't be very specific, but one approach
is to use "system", like this (assumes DOS or Windows; alter as
necessary for Unix, Linux, OS2, Mac, or whatever):
#include <iostream>
#include <fstream>
int SomeFunction(int SomeParameter)
{
// some code
system("dir >> C:\\TEMP\\DIRFILE.TXT"); // make dir file
ifstream IFS("C:\\TEMP\\DIRFILE.TXT"); // open dir file
// read and use contents of dir file
IFS.close(); // close dir file
system("erase C:\\TEMP\\DIRFILE.TXT"); // erase dir file
// some more code
return 0;
}
(For Unix or Linux, replace "dir >> C:\\TEMP\\DIRFILE.TXT" with
"list >> /etc/dirfile.txt" or some such thing.)
Another way, which can be more efficient (but less portable),
is to use the platform-specific C extensions that almost certainly
come with your compiler (whatever that may be), like so:
#include <iostream>
#include <list>
#include <string>
int SomeFunction(int SomeParameter)
{
// some code
std::list<std::string> Blat;
SomePlatformSpecificFunction(Blat); // put list of files in Blat
// read and use list of files in Blat
// some more code
return 0;
}
(Read the documentation for your operating system and your compiler
for more information.)
Hope that gives you some ideas.
--
Robbie Hatley
Tustin, CA, USA
lone wolf intj at pac bell dot net
home dot pac bell dot net slant earnur slant