summaryrefslogtreecommitdiff
path: root/src/resources/wallpaper.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-02-14 18:00:20 +0300
committerAndrei Karas <akaras@inbox.ru>2017-02-14 18:00:20 +0300
commit5283a59db971ec2038149bf26ad9b3cbc4924449 (patch)
treec2f208b197a3726d6358ca707b64d01887bb6151 /src/resources/wallpaper.cpp
parent59146da772888a295bbf8613f32bce5dd7bb00ab (diff)
downloadmanaplus-5283a59db971ec2038149bf26ad9b3cbc4924449.tar.gz
manaplus-5283a59db971ec2038149bf26ad9b3cbc4924449.tar.bz2
manaplus-5283a59db971ec2038149bf26ad9b3cbc4924449.tar.xz
manaplus-5283a59db971ec2038149bf26ad9b3cbc4924449.zip
Add virtlist for file names enumeration in virtfs.
Diffstat (limited to 'src/resources/wallpaper.cpp')
-rw-r--r--src/resources/wallpaper.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index b98b9eb67..63a8d755c 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -27,6 +27,7 @@
#include "resources/wallpaperdata.h"
#include "utils/virtfs.h"
+#include "utils/virtlist.h"
#include <algorithm>
@@ -84,19 +85,19 @@ void Wallpaper::loadWallpapers()
{
wallpaperData.clear();
initDefaultWallpaperPaths();
- char **const imgs = VirtFs::enumerateFiles(wallpaperPath.c_str());
+ VirtList *const imgs = VirtFs::enumerateFiles(wallpaperPath);
- for (char *const *i = imgs; *i; i++)
+ FOR_EACH (StringVectCIter, i, imgs->names)
{
+ // First, get the base filename of the image:
+ std::string filename = *i;
// If the backup file is found, we tell it.
- if (strncmp (*i, wallpaperFile.c_str(), strlen(*i)) == 0)
+ if (filename.find(wallpaperFile) != std::string::npos)
haveBackup = true;
// If the image format is terminated by: "_<width>x<height>.png"
// It is taken as a potential wallpaper.
- // First, get the base filename of the image:
- std::string filename = *i;
size_t separator = filename.rfind('_');
filename = filename.substr(0, separator);
@@ -104,12 +105,16 @@ void Wallpaper::loadWallpapers()
separator = filename.find('%');
if (separator == std::string::npos)
{
+ std::string name = filename;
// Then, append the width and height search mask.
filename.append("_%10dx%10d.png");
int width;
int height;
- if (sscanf(*i, filename.c_str(), &width, &height) == 2)
+ if (sscanf(name.c_str(),
+ filename.c_str(),
+ &width,
+ &height) == 2)
{
WallpaperData wp;
wp.filename = wallpaperPath;