From 5283a59db971ec2038149bf26ad9b3cbc4924449 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 14 Feb 2017 18:00:20 +0300 Subject: Add virtlist for file names enumeration in virtfs. --- src/resources/wallpaper.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/resources/wallpaper.cpp') 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 @@ -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: "_x.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; -- cgit v1.2.3-60-g2f50