PDA

View Full Version : Read output of ls into a string?



Zorgoth
June 7th, 2010, 07:06 PM
How can I read the output of ls into a string so that I can use C++ to read all the files in a directory? Also, is there a way to make it so C++ will know which objects are folders?

radeon21
June 7th, 2010, 08:06 PM
You probably don't want to use ls to read into a directory with C++. Take a look at POSIX functions like opendir() (http://www.opengroup.org/onlinepubs/009695399/functions/opendir.html)

I'm not an expert at all, but I think this is the direction you should be going. Good luck!