diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-02-14 18:00:20 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-02-14 18:00:20 +0300 |
commit | 5283a59db971ec2038149bf26ad9b3cbc4924449 (patch) | |
tree | c2f208b197a3726d6358ca707b64d01887bb6151 /src/resources/wallpaper.cpp | |
parent | 59146da772888a295bbf8613f32bce5dd7bb00ab (diff) | |
download | plus-5283a59db971ec2038149bf26ad9b3cbc4924449.tar.gz plus-5283a59db971ec2038149bf26ad9b3cbc4924449.tar.bz2 plus-5283a59db971ec2038149bf26ad9b3cbc4924449.tar.xz plus-5283a59db971ec2038149bf26ad9b3cbc4924449.zip |
Add virtlist for file names enumeration in virtfs.
Diffstat (limited to 'src/resources/wallpaper.cpp')
-rw-r--r-- | src/resources/wallpaper.cpp | 17 |
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; |