From 06a892ef769729bc875985ba49838771291d2e15 Mon Sep 17 00:00:00 2001 From: Mark Olsen Date: Sat, 19 Aug 2006 22:09:55 +0000 Subject: [PATCH] Sys_EnumerateFiles() for MorphOS git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2373 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/sys_morphos.c | 67 ++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/engine/client/sys_morphos.c b/engine/client/sys_morphos.c index 308e7cf11..46860c58d 100755 --- a/engine/client/sys_morphos.c +++ b/engine/client/sys_morphos.c @@ -181,7 +181,72 @@ int Sys_FileTime(char *path) int Sys_EnumerateFiles(char *gpath, char *match, int (*func)(char *, int, void *), void *parm) { - return true; + char *pattern; + char pattrans[256]; + char finddir[256]; + char findpattern[514]; + char filename[256]; + int i, j; + BPTR lock; + struct FileInfoBlock fib; + int ret = false; + + snprintf(finddir, sizeof(finddir), "%s/%s", gpath, match); + + pattern = strrchr(finddir, '/'); + if (pattern) + { + finddir[((unsigned int)(pattern-finddir))] = 0; + pattern++; + } + + for(i=0,j=0;i= 0) + { + ret = true; + + while(ExNext(lock, &fib)) + { + if (MatchPatternNoCase(findpattern, fib.fib_FileName)) + { + snprintf(filename, sizeof(filename), "%s%s", fib.fib_FileName, fib.fib_DirEntryType>=0?"/":""); + if (func(filename, fib.fib_Size, parm) == 0) + { + ret = false; + break; + } + } + } + } + } + + UnLock(lock); + } + + return ret; } void Sys_mkdir(char *path)