From 3d25f7825a7e3df85a8077aec8b7bbce5fde8dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Stenberg?= Date: Mon, 27 May 2002 09:13:24 +0000 Subject: Now supports multiple concurrent opendir() git-svn-id: svn://svn.rockbox.org/rockbox/trunk@727 a1c6a512-1295-4272-9138-f99709370657 --- firmware/common/dir.c | 53 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'firmware/common/dir.c') diff --git a/firmware/common/dir.c b/firmware/common/dir.c index e1f4c06..5fb1415 100644 --- a/firmware/common/dir.c +++ b/firmware/common/dir.c @@ -17,15 +17,16 @@ * ****************************************************************************/ #include +#include #include #include #include "fat.h" #include "dir.h" #include "debug.h" -static DIR thedir; -static struct dirent theent; -static bool busy=false; +#define MAX_OPEN_DIRS 8 + +static DIR opendirs[MAX_OPEN_DIRS]; DIR* opendir(char* name) { @@ -33,20 +34,30 @@ DIR* opendir(char* name) char* part; char* end; struct fat_direntry entry; - struct fat_dir* dir = &(thedir.fatdir); + int dd; + + /* find a free dir descriptor */ + for ( dd=0; ddbusy=false; return 0; } struct dirent* readdir(DIR* dir) { struct fat_direntry entry; + struct dirent* theent = &(dir->theent); if (fat_getnext(&(dir->fatdir),&entry) < 0) return NULL; @@ -95,12 +108,12 @@ struct dirent* readdir(DIR* dir) if ( !entry.name[0] ) return NULL; - strncpy(theent.d_name, entry.name, sizeof( theent.d_name ) ); - theent.attribute = entry.attr; - theent.size = entry.filesize; - theent.startcluster = entry.firstcluster; + strncpy(theent->d_name, entry.name, sizeof( theent->d_name ) ); + theent->attribute = entry.attr; + theent->size = entry.filesize; + theent->startcluster = entry.firstcluster; - return &theent; + return theent; } /* -- cgit v1.1