From 5c93947d264c359590d207bab4f36d7f6884645f Mon Sep 17 00:00:00 2001 From: stpohle Date: Tue, 6 May 2003 21:34:07 +0000 Subject: [PATCH] s_dirfilter added... --- src/sysfunc.c | 26 +++++++++++++++++++++++++- src/sysfunc.h | 3 ++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/sysfunc.c b/src/sysfunc.c index 36cf55e..56029e0 100644 --- a/src/sysfunc.c +++ b/src/sysfunc.c @@ -1,4 +1,4 @@ -/* $Id: sysfunc.c,v 1.3 2003/05/06 20:48:54 stpohle Exp $ +/* $Id: sysfunc.c,v 1.4 2003/05/06 21:34:07 stpohle Exp $ sysfunc.c - this file hold some routines for the system functions.. like d_delay */ @@ -87,7 +87,31 @@ s_gethomedir () closedir (dp); if (entrynr == 0) return NULL; + direntrys[entrynr - 1].next = NULL; + return &direntrys[0]; }; + +_direntry *s_dirfilter (_direntry *dirstart, signed char dirflags) { + _direntry *newstart = NULL, *pos = NULL, *old = NULL; + + for (pos = dirstart; pos != NULL; pos = pos->next) + if (pos->name[0] != '.' && (pos->flags & dirflags) != 0) { + if (newstart == NULL) { + newstart = pos; + old = pos; + } + else { + old->next = pos; + old = pos; + } + } + + if (old != NULL) + old->next = NULL; + + return newstart; +}; + diff --git a/src/sysfunc.h b/src/sysfunc.h index dbb2546..c12a77b 100644 --- a/src/sysfunc.h +++ b/src/sysfunc.h @@ -1,4 +1,4 @@ -/* $Id: sysfunc.h,v 1.1 2003/05/06 12:09:22 stpohle Exp $ */ +/* $Id: sysfunc.h,v 1.2 2003/05/06 21:34:07 stpohle Exp $ */ /* include some system near functions */ #ifndef _SYSFUNC_H_ @@ -22,5 +22,6 @@ extern int s_random (int maxnr); extern char *s_gethomedir (); extern _direntry *s_getdir (char *path); +extern _direntry *s_dirfilter (_direntry *dirstart, signed char dirflags); #endif \ No newline at end of file