If you've got a recent version of GCC, you should be able to use std::filesystem. If not, try boost::filesystem. They both have methods to walk the file system. If you're masochistic, you could use ftw() include <ftw.h>.
... Yes, like the list of files output from blender like this;
myout_01.png
myout_02.png
myout_03.png
myout_04.png
Instead of strcmp in this situation, since you've already got a vector of strings with those file names, I would prefer to use the find() function from the string class.
1 2 3 4 5 6
if(files[i].find("myout_", 0) != std::string::npos )
{
// parse the number out of the file if you need that info
// do some processing on the file
//etc
}
Also the string's substr function might be useful for finding all files of a certain extension
1 2 3 4 5
string fName = files[i];
if(fName.substr(fName.length() - 4) == ".ext")
{
// found a file that ends in ".ext", now do something with it...
}
Out of curiosity, have you looked into elb's suggestion about std::filesystem? I hadn't read much into c++17 and was not aware of all that it offers when I suggested dirent.h, and it offers it in a cross-system manner which means only learning one library and being able to build the same code on almost any system... Nothing wrong with dirent.h, but there may be many benefits to the other option...
Ok that's fantastic. I have my first file searching program, that's fab. Can you guys suggest any api's and libraries I should be learning to build a gui for it?
There are several methods in the link above. It looks to me that the easiest is just to open the path as a folder using openddir(filePath), and if it returns NULL then it either is a file, the path is incorrect, or you do not have permissions to read that folder.
If you need more specific info on what the path is, then you could use the stat.h method.
you mean not show folders at all?
rewire the logic there to: if it is a file, print the name, else do not print the name (no else statement, its an empty / implied do nothing else).