From 3cb15a8f777bd9907d8dc4ba57774c762ec1f67f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 6 Jan 2014 13:29:14 +0300 Subject: simplify files enumerate function usage. --- src/utils/files.cpp | 13 ++++++++++++- src/utils/files.h | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src/utils') diff --git a/src/utils/files.cpp b/src/utils/files.cpp index 206a4d4bd..72a4b2cb5 100644 --- a/src/utils/files.cpp +++ b/src/utils/files.cpp @@ -22,10 +22,10 @@ #if defined(ANDROID) || defined(__native_client__) #include "resources/resourcemanager.h" -#include "utils/physfstools.h" #endif #include "utils/mkdir.h" +#include "utils/physfstools.h" #include "localconsts.h" @@ -196,3 +196,14 @@ int Files::copyFile(const std::string &restrict srcName, fclose(dstFile); return 0; } + +void Files::getFiles(const std::string &path, StringVect &list) +{ + char **fonts = PhysFs::enumerateFiles(path.c_str()); + for (char **i = fonts; *i; i++) + { + if (!PhysFs::isDirectory((path + *i).c_str())) + list.push_back(*i); + } + PhysFs::freeList(fonts); +} diff --git a/src/utils/files.h b/src/utils/files.h index cc578464a..b7b5bbc31 100644 --- a/src/utils/files.h +++ b/src/utils/files.h @@ -21,6 +21,8 @@ #ifndef UTILS_FILES_H #define UTILS_FILES_H +#include "utils/stringvector.h" + #include #include "localconsts.h" @@ -52,6 +54,8 @@ namespace Files int copyFile(const std::string &restrict pFrom, const std::string &restrict pTo); + + void getFiles(const std::string &path, StringVect &list); } // namespace Files #endif // UTILS_FILES_H -- cgit v1.2.3-70-g09d2