Question

is there a specific way to directly get how many files there is in a given folder? Like:

fol = openfolder("MyFolderPath");
int n = fol.getNumberOfFiles();

Or do I have to open the folder and iterate through all the files?

I'm reading obj files from Blender and trying to load in an animation. (lots of vertices, 1 file for each frame)

Also, for preformance... Is it bad to create your own animation class, using this method to store frames?

vector <vector <float>> frames;
vector <float> verticesForThisFrame;
verticesForThisFrame.push_back(readX());
verticesForThisFrame.push_back(readY());
verticesForThisFrame.push_back(readZ());
frames.push_back(verticesForThisFrame);

If it's very inefficient, what do you suggest I do?

EDIT: I use SDL to open a window, and OpenGL for graphics.

Was it helpful?

Solution

It depends what framework/library you are using. You may be forced to open folder and iterate through its content, like

for( directory_iterator it(YourPath); it != directory_iterator(); ++it)
{
   // increment variable here
}

in case of boost, or get the files count like

QDir.count() // returns the total count of files and directories in the directory
             // use flags QDir::Filters with QDir::NoDotAndDotDot to exclude
             // . and ..

in case of Qt.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top