diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-01-25 18:40:05 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-01-25 18:40:05 +0300 |
commit | 2157b8c6629cea79801566244fc3f1d8491e91be (patch) | |
tree | fb999e7d464c70511f13472da0fba86749b8d737 /src/utils/files.cpp | |
parent | e89fb908638196c9484a2038e3f3eb18db6ef4ee (diff) | |
download | ManaVerse-2157b8c6629cea79801566244fc3f1d8491e91be.tar.gz ManaVerse-2157b8c6629cea79801566244fc3f1d8491e91be.tar.bz2 ManaVerse-2157b8c6629cea79801566244fc3f1d8491e91be.tar.xz ManaVerse-2157b8c6629cea79801566244fc3f1d8491e91be.zip |
Add file utils function getFilesInDir.
Diffstat (limited to 'src/utils/files.cpp')
-rw-r--r-- | src/utils/files.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/utils/files.cpp b/src/utils/files.cpp index e694a2b9e..0a3f3eb92 100644 --- a/src/utils/files.cpp +++ b/src/utils/files.cpp @@ -31,7 +31,9 @@ #include "utils/mkdir.h" #include "utils/paths.h" #include "utils/physfstools.h" +#include "utils/stringutils.h" +#include <algorithm> #include <dirent.h> #include <fstream> #include <sstream> @@ -363,3 +365,19 @@ void Files::deleteFilesInDirectory(std::string path) if (dir) closedir(dir); } + +void Files::getFilesInDir(const std::string &dir, + StringVect &list, + const std::string &ext) +{ + const std::string path = dir + "/"; + StringVect tempList; + Files::getFilesWithDir(path, tempList); + FOR_EACH (StringVectCIter, it, tempList) + { + const std::string &str = *it; + if (findLast(str, ext)) + list.push_back(str); + } + std::sort(list.begin(), list.end()); +} |