mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
cReadDir::Next() now skips directory entries "." and ".."
This commit is contained in:
parent
f1eecdeb1c
commit
882691e32f
1
HISTORY
1
HISTORY
@ -6884,3 +6884,4 @@ Video Disk Recorder Revision History
|
|||||||
- The DVB device adapters/frontends are now probed by scanning the /dev/dvb directory
|
- The DVB device adapters/frontends are now probed by scanning the /dev/dvb directory
|
||||||
instead of looping through adapter/frontend numbers. This allows for "holes" in the
|
instead of looping through adapter/frontend numbers. This allows for "holes" in the
|
||||||
device numbering.
|
device numbering.
|
||||||
|
- cReadDir::Next() now skips directory entries "." and "..".
|
||||||
|
@ -63,3 +63,7 @@ VDR Plugin 'pictures' Revision History
|
|||||||
2012-01-08:
|
2012-01-08:
|
||||||
|
|
||||||
- Added option -o to pic2mpg.
|
- Added option -o to pic2mpg.
|
||||||
|
|
||||||
|
2012-02-17:
|
||||||
|
|
||||||
|
- cReadDir::Next() now skips directory entries "." and "..".
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* See the README file for copyright information and how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: entry.c 1.3 2008/02/17 13:42:34 kls Exp $
|
* $Id: entry.c 2.1 2012/02/17 14:00:28 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "entry.h"
|
#include "entry.h"
|
||||||
@ -48,7 +48,6 @@ void cPictureEntry::Load(void) const
|
|||||||
if (d.Ok()) {
|
if (d.Ok()) {
|
||||||
struct dirent *e;
|
struct dirent *e;
|
||||||
while ((e = d.Next()) != NULL) {
|
while ((e = d.Next()) != NULL) {
|
||||||
if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..")) {
|
|
||||||
struct stat ds;
|
struct stat ds;
|
||||||
if (stat(AddDirectory(Directory, e->d_name), &ds) == 0) {
|
if (stat(AddDirectory(Directory, e->d_name), &ds) == 0) {
|
||||||
if (!entries)
|
if (!entries)
|
||||||
@ -56,7 +55,6 @@ void cPictureEntry::Load(void) const
|
|||||||
entries->Add(new cPictureEntry(e->d_name, this, S_ISDIR(ds.st_mode)));
|
entries->Add(new cPictureEntry(e->d_name, this, S_ISDIR(ds.st_mode)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (entries)
|
if (entries)
|
||||||
entries->Sort();
|
entries->Sort();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* See the README file for copyright information and how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: pictures.c 2.3 2011/02/20 16:50:01 kls Exp $
|
* $Id: pictures.c 2.4 2012/02/17 14:00:48 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
@ -11,7 +11,7 @@
|
|||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
|
||||||
static const char *VERSION = "0.1.0";
|
static const char *VERSION = "0.1.1";
|
||||||
static const char *DESCRIPTION = trNOOP("A simple picture viewer");
|
static const char *DESCRIPTION = trNOOP("A simple picture viewer");
|
||||||
static const char *MAINMENUENTRY = trNOOP("Pictures");
|
static const char *MAINMENUENTRY = trNOOP("Pictures");
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: recording.c 2.48 2012/02/16 11:53:13 kls Exp $
|
* $Id: recording.c 2.49 2012/02/17 13:57:05 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "recording.h"
|
#include "recording.h"
|
||||||
@ -1109,7 +1109,6 @@ void cRecordings::ScanVideoDir(const char *DirName, bool Foreground, int LinkLev
|
|||||||
cReadDir d(DirName);
|
cReadDir d(DirName);
|
||||||
struct dirent *e;
|
struct dirent *e;
|
||||||
while ((Foreground || Running()) && (e = d.Next()) != NULL) {
|
while ((Foreground || Running()) && (e = d.Next()) != NULL) {
|
||||||
if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..")) {
|
|
||||||
cString buffer = AddDirectory(DirName, e->d_name);
|
cString buffer = AddDirectory(DirName, e->d_name);
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (lstat(buffer, &st) == 0) {
|
if (lstat(buffer, &st) == 0) {
|
||||||
@ -1146,7 +1145,6 @@ void cRecordings::ScanVideoDir(const char *DirName, bool Foreground, int LinkLev
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool cRecordings::StateChanged(int &State)
|
bool cRecordings::StateChanged(int &State)
|
||||||
{
|
{
|
||||||
|
4
themes.c
4
themes.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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"
|
#include "themes.h"
|
||||||
@ -243,7 +243,6 @@ bool cThemes::Load(const char *SkinName)
|
|||||||
cReadDir d(themesDirectory);
|
cReadDir d(themesDirectory);
|
||||||
struct dirent *e;
|
struct dirent *e;
|
||||||
while ((e = d.Next()) != NULL) {
|
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)] == '-') {
|
if (strstr(e->d_name, SkinName) == e->d_name && e->d_name[strlen(SkinName)] == '-') {
|
||||||
cString FileName = AddDirectory(themesDirectory, e->d_name);
|
cString FileName = AddDirectory(themesDirectory, e->d_name);
|
||||||
cTheme Theme;
|
cTheme Theme;
|
||||||
@ -276,7 +275,6 @@ bool cThemes::Load(const char *SkinName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return numThemes > 0;
|
return numThemes > 0;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
18
tools.c
18
tools.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: tools.c 2.20 2012/01/11 11:21:43 kls Exp $
|
* $Id: tools.c 2.21 2012/02/17 13:58:49 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
@ -384,7 +384,6 @@ bool RemoveFileOrDir(const char *FileName, bool FollowSymlinks)
|
|||||||
if (d.Ok()) {
|
if (d.Ok()) {
|
||||||
struct dirent *e;
|
struct dirent *e;
|
||||||
while ((e = d.Next()) != NULL) {
|
while ((e = d.Next()) != NULL) {
|
||||||
if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..")) {
|
|
||||||
cString buffer = AddDirectory(FileName, e->d_name);
|
cString buffer = AddDirectory(FileName, e->d_name);
|
||||||
if (FollowSymlinks) {
|
if (FollowSymlinks) {
|
||||||
struct stat st2;
|
struct stat st2;
|
||||||
@ -416,7 +415,6 @@ bool RemoveFileOrDir(const char *FileName, bool FollowSymlinks)
|
|||||||
LOG_ERROR_STR(*buffer);
|
LOG_ERROR_STR(*buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
LOG_ERROR_STR(FileName);
|
LOG_ERROR_STR(FileName);
|
||||||
return false;
|
return false;
|
||||||
@ -442,7 +440,7 @@ bool RemoveEmptyDirectories(const char *DirName, bool RemoveThis)
|
|||||||
bool empty = true;
|
bool empty = true;
|
||||||
struct dirent *e;
|
struct dirent *e;
|
||||||
while ((e = d.Next()) != NULL) {
|
while ((e = d.Next()) != NULL) {
|
||||||
if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..") && strcmp(e->d_name, "lost+found")) {
|
if (strcmp(e->d_name, "lost+found")) {
|
||||||
cString buffer = AddDirectory(DirName, e->d_name);
|
cString buffer = AddDirectory(DirName, e->d_name);
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(buffer, &st) == 0) {
|
if (stat(buffer, &st) == 0) {
|
||||||
@ -480,7 +478,6 @@ int DirSizeMB(const char *DirName)
|
|||||||
int size = 0;
|
int size = 0;
|
||||||
struct dirent *e;
|
struct dirent *e;
|
||||||
while (size >= 0 && (e = d.Next()) != NULL) {
|
while (size >= 0 && (e = d.Next()) != NULL) {
|
||||||
if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..")) {
|
|
||||||
cString buffer = AddDirectory(DirName, e->d_name);
|
cString buffer = AddDirectory(DirName, e->d_name);
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(buffer, &st) == 0) {
|
if (stat(buffer, &st) == 0) {
|
||||||
@ -499,7 +496,6 @@ int DirSizeMB(const char *DirName)
|
|||||||
size = -1;
|
size = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1320,7 +1316,13 @@ cReadDir::~cReadDir()
|
|||||||
|
|
||||||
struct dirent *cReadDir::Next(void)
|
struct dirent *cReadDir::Next(void)
|
||||||
{
|
{
|
||||||
return directory && readdir_r(directory, &u.d, &result) == 0 ? result : NULL;
|
if (directory) {
|
||||||
|
while (readdir_r(directory, &u.d, &result) == 0 && result) {
|
||||||
|
if (strcmp(result->d_name, ".") && strcmp(result->d_name, ".."))
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- cStringList -----------------------------------------------------------
|
// --- cStringList -----------------------------------------------------------
|
||||||
@ -1362,7 +1364,6 @@ bool cFileNameList::Load(const char *Directory, bool DirsOnly)
|
|||||||
struct dirent *e;
|
struct dirent *e;
|
||||||
if (d.Ok()) {
|
if (d.Ok()) {
|
||||||
while ((e = d.Next()) != NULL) {
|
while ((e = d.Next()) != NULL) {
|
||||||
if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..")) {
|
|
||||||
if (DirsOnly) {
|
if (DirsOnly) {
|
||||||
struct stat ds;
|
struct stat ds;
|
||||||
if (stat(AddDirectory(Directory, e->d_name), &ds) == 0) {
|
if (stat(AddDirectory(Directory, e->d_name), &ds) == 0) {
|
||||||
@ -1372,7 +1373,6 @@ bool cFileNameList::Load(const char *Directory, bool DirsOnly)
|
|||||||
}
|
}
|
||||||
Append(strdup(e->d_name));
|
Append(strdup(e->d_name));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Sort();
|
Sort();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user