#include #include #include #include // get models from a given directory and add them to a given vector void getModelsFromDir(std::string path, std::vector* vector) { DIR* dir; struct dirent* ent; if ((dir = opendir(path.c_str())) != NULL) { while ((ent = readdir(dir)) != NULL) { std::string filename = ent->d_name; size_t fmaPos = filename.find(".fma"); // position of ".fma" in filename if (fmaPos == std::string::npos) { // filename does not have ".fma" in it continue; } filename.erase(fmaPos); vector->push_back(filename); } closedir(dir); } } std::vector listModels() { std::vector modelList; getModelsFromDir(prefixCustom + "models", &modelList); getModelsFromDir(prefixDefault + "models", &modelList); getModelsFromDir("models", &modelList); /* for (int i = 0; i < modelList.size(); i++) { std::cout << "Detected model: " << modelList.at(i) << std::endl; } */ return modelList; }