diff --git a/source/code/listFiles.cpp b/source/code/listFiles.cpp index 9bb19fd..cf2bbd0 100644 --- a/source/code/listFiles.cpp +++ b/source/code/listFiles.cpp @@ -31,9 +31,7 @@ using namespace std; void ListFiles::setDirectory(const string& directory) { - for (int i=0; id_name; if (!isInList(name) && name[0]!='.' ) { - nrOfFiles++; - filenames[nrOfFiles] = name; + filenames.push_back(name); } } closedir(DirectoryPointer); @@ -82,8 +78,8 @@ void ListFiles::setDirectory(const string& directory) { } bool ListFiles::isInList(const string& name) { - for (int i=0; (i<=nrOfFiles); i++) { - if (0==strcmp(name.c_str(),filenames[i].c_str())) { + for (int i=0; i< filenames.size(); i++) { + if (name == filenames.at(i) ) { return true; } } @@ -99,11 +95,10 @@ void ListFiles::setDirectory2(const string& dic) { if (!DirectoryPointer) { return; } - while ((dp=readdir(DirectoryPointer))&&(nrOfFilesd_name; if (!isInList(name) && name != "." && name != "..") { - nrOfFiles++; - filenames[nrOfFiles] = name; + filenames.push_back(name); } } closedir(DirectoryPointer); @@ -113,7 +108,7 @@ void ListFiles::setDirectory2(const string& dic) { } string ListFiles::getFileName(int nr) { - if (startFileNr+nr #include -#define MAX_NR_OF_FILES 253 #if defined (_WIN32) #define FIRST_FILE 2 #else @@ -44,18 +43,17 @@ class ListFiles { private: int startFileNr; //The first fileto belisted - std::string filenames[MAX_NR_OF_FILES]; - int nrOfFiles; + std::vector filenames; #if defined(_WIN32) WIN32_FIND_DATA FindFileData; HANDLE hFind; #endif - bool isInList(const std::string &name); //The name is already in the list + bool isInList(const std::string& name); //The name is already in the list public: //ListFiles(); //~ListFiles(); - void setDirectory(const std::string &dictory); //Find file in BlockAttack folder - void setDirectory2(const std::string &dictory); //Second directory we also look in + void setDirectory(const std::string& dictory); //Find file in BlockAttack folder + void setDirectory2(const std::string& dictory); //Second directory we also look in //void setDirecctoryInHome(string dictory); //Find files in home folder (it should work...) std::string getFileName(int); //Returns the filename of a file bool fileExists(int);