summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/files.cc
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source/files.cc')
-rw-r--r--crawl-ref/source/files.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index b5dc708b08..3650f8899d 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -225,7 +225,6 @@ bool get_dos_compatible_file_name(std::string *fname)
}
#endif
-
// Returns the names of all files in the given directory. Note that the
// filenames returned are relative to the directory.
std::vector<std::string> get_dir_files(const std::string &dirname)
@@ -268,6 +267,17 @@ std::vector<std::string> get_dir_files(const std::string &dirname)
return (files);
}
+std::vector<std::string> get_dir_files_ext(const std::string &dir,
+ const std::string &ext)
+{
+ const std::vector<std::string> allfiles(get_dir_files(dir));
+ std::vector<std::string> filtered;
+ for (int i = 0, size = allfiles.size(); i < size; ++i)
+ if (ends_with(allfiles[i], ext))
+ filtered.push_back(allfiles[i]);
+ return (filtered);
+}
+
std::string get_parent_directory(const std::string &filename)
{
std::string::size_type pos = filename.rfind(FILE_SEPARATOR);