#ifndef TURNINSTRUCTIONSLIST_H_ #define TURNINSTRUCTIONSLIST_H_ #include #include #include #include #include #include #include #include #include #include "./TurnInstructions.h" struct TurnInstructionsListClass { // Class to go over directory hierachy list tilist; vector languages; TurnInstructionsListClass(){}; TurnInstructionsListClass(std::string path){ vector archivos; vector::iterator posArchivo; posArchivo = archivos.begin(); FindFile(path.c_str(), archivos); TurnInstructionsClass ti; // Vector with the file names to read for (int i = 0; i < archivos.size(); ++i){ ti = TurnInstructionsClass(archivos.at(i)); posArchivo++; tilist.push_back(ti); } }; void FindFile (const char dirname[], vector &archivos){ static DIR *dir; static struct dirent *mi_dirent; // Check if the directory have opened correctly if((dir = opendir(dirname)) == NULL) cout << "Fault in opendir" << endl;; // Go over directory content while ((mi_dirent = readdir(dir)) != NULL){ // If it's not (.) or (..) if (strcmp (mi_dirent->d_name, ".") != 0 && strcmp (mi_dirent->d_name, "..") != 0){ struct stat structura; // Read the complete path string dirnameString = dirname; string nameFile = mi_dirent->d_name; string pathFile = dirnameString + "/" + nameFile; if (stat(pathFile.c_str(), &structura) < 0){ cout << "Fault in stat" << endl; }else if (structura.st_mode & S_IFREG){ archivos.reserve(archivos.size() + 2); archivos.push_back(pathFile); boost::to_upper(nameFile); languages.reserve(languages.size() + 2); languages.push_back(nameFile); }else if(structura.st_mode & S_IFDIR){ FindFile(mi_dirent->d_name, archivos); } } } if(closedir(dir) == -1){ cout << "Fault in closedir" << endl; } } TurnInstructionsClass getTurnInstructions(std::string language){ boost::to_upper(language); list ::iterator pos; int index = -1; // In case the language is empty if(index == -1 && language == ""){ for(int i=0; i