summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-06 13:29:14 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-06 13:29:14 +0300
commit3cb15a8f777bd9907d8dc4ba57774c762ec1f67f (patch)
treeec991d4a6c5c9a528163dad15a284674d478e64b /src
parent5ab85579f493e951d0042cd879cc848d4c7c871b (diff)
downloadplus-3cb15a8f777bd9907d8dc4ba57774c762ec1f67f.tar.gz
plus-3cb15a8f777bd9907d8dc4ba57774c762ec1f67f.tar.bz2
plus-3cb15a8f777bd9907d8dc4ba57774c762ec1f67f.tar.xz
plus-3cb15a8f777bd9907d8dc4ba57774c762ec1f67f.zip
simplify files enumerate function usage.
Diffstat (limited to 'src')
-rw-r--r--src/gui/theme.cpp29
-rw-r--r--src/utils/files.cpp13
-rw-r--r--src/utils/files.h4
3 files changed, 19 insertions, 27 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 760169d07..f329ada74 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -33,6 +33,7 @@
#include "resources/resourcemanager.h"
#include "utils/dtor.h"
+#include "utils/files.h"
#include "utils/physfstools.h"
#include <algorithm>
@@ -649,37 +650,13 @@ bool Theme::tryThemePath(const std::string &themeName)
void Theme::fillSkinsList(StringVect &list)
{
- char **skins = PhysFs::enumerateFiles(
- branding.getStringValue("guiThemePath").c_str());
-
- for (char **i = skins; *i; i++)
- {
- if (PhysFs::isDirectory((
- branding.getStringValue("guiThemePath") + *i).c_str()))
- {
- list.push_back(*i);
- }
- }
-
- PhysFs::freeList(skins);
+ Files::getFiles(branding.getStringValue("guiThemePath"), list);
}
void Theme::fillFontsList(StringVect &list)
{
PHYSFS_permitSymbolicLinks(1);
- char **fonts = PhysFs::enumerateFiles(
- branding.getStringValue("fontsPath").c_str());
-
- for (char **i = fonts; *i; i++)
- {
- if (!PhysFs::isDirectory((
- branding.getStringValue("fontsPath") + *i).c_str()))
- {
- list.push_back(*i);
- }
- }
-
- PhysFs::freeList(fonts);
+ Files::getFiles(branding.getStringValue("fontsPath"), list);
PHYSFS_permitSymbolicLinks(0);
}
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 <string>
#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