mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
cReadDir::Next() now skips directory entries "." and ".."
This commit is contained in:
60
themes.c
60
themes.c
@@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* how to reach the author.
|
||||
*
|
||||
* $Id: themes.c 2.1 2011/02/25 14:45:18 kls Exp $
|
||||
* $Id: themes.c 2.2 2012/02/17 13:57:32 kls Exp $
|
||||
*/
|
||||
|
||||
#include "themes.h"
|
||||
@@ -243,37 +243,35 @@ bool cThemes::Load(const char *SkinName)
|
||||
cReadDir d(themesDirectory);
|
||||
struct dirent *e;
|
||||
while ((e = d.Next()) != NULL) {
|
||||
if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..")) {
|
||||
if (strstr(e->d_name, SkinName) == e->d_name && e->d_name[strlen(SkinName)] == '-') {
|
||||
cString FileName = AddDirectory(themesDirectory, e->d_name);
|
||||
cTheme Theme;
|
||||
if (Theme.Load(*FileName, true)) {
|
||||
if (char **NewBuffer = (char **)realloc(names, (numThemes + 1) * sizeof(char *))) {
|
||||
names = NewBuffer;
|
||||
names[numThemes] = strdup(Theme.Name());
|
||||
}
|
||||
else {
|
||||
esyslog("ERROR: out of memory");
|
||||
break;
|
||||
}
|
||||
if (char **NewBuffer = (char **)realloc(fileNames, (numThemes + 1) * sizeof(char *))) {
|
||||
fileNames = NewBuffer;
|
||||
fileNames[numThemes] = strdup(*FileName);
|
||||
}
|
||||
else {
|
||||
esyslog("ERROR: out of memory");
|
||||
break;
|
||||
}
|
||||
if (char **NewBuffer = (char **)realloc(descriptions, (numThemes + 1) * sizeof(char *))) {
|
||||
descriptions = NewBuffer;
|
||||
descriptions[numThemes] = strdup(Theme.Description());
|
||||
}
|
||||
else {
|
||||
esyslog("ERROR: out of memory");
|
||||
break;
|
||||
}
|
||||
numThemes++;
|
||||
if (strstr(e->d_name, SkinName) == e->d_name && e->d_name[strlen(SkinName)] == '-') {
|
||||
cString FileName = AddDirectory(themesDirectory, e->d_name);
|
||||
cTheme Theme;
|
||||
if (Theme.Load(*FileName, true)) {
|
||||
if (char **NewBuffer = (char **)realloc(names, (numThemes + 1) * sizeof(char *))) {
|
||||
names = NewBuffer;
|
||||
names[numThemes] = strdup(Theme.Name());
|
||||
}
|
||||
else {
|
||||
esyslog("ERROR: out of memory");
|
||||
break;
|
||||
}
|
||||
if (char **NewBuffer = (char **)realloc(fileNames, (numThemes + 1) * sizeof(char *))) {
|
||||
fileNames = NewBuffer;
|
||||
fileNames[numThemes] = strdup(*FileName);
|
||||
}
|
||||
else {
|
||||
esyslog("ERROR: out of memory");
|
||||
break;
|
||||
}
|
||||
if (char **NewBuffer = (char **)realloc(descriptions, (numThemes + 1) * sizeof(char *))) {
|
||||
descriptions = NewBuffer;
|
||||
descriptions[numThemes] = strdup(Theme.Description());
|
||||
}
|
||||
else {
|
||||
esyslog("ERROR: out of memory");
|
||||
break;
|
||||
}
|
||||
numThemes++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user