From 8c70e4a8c2c27e9b95ad8dd89eb034c08f63d0df Mon Sep 17 00:00:00 2001 From: yabause Date: Wed, 7 Jun 2006 22:52:24 +0000 Subject: [PATCH] Added some code to fs-linux.c, it's now working enough to display files but doesn't parse subdirs. The code needs some cleaning... --- desmume/src/fs-linux.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/desmume/src/fs-linux.c b/desmume/src/fs-linux.c index fef718c64..65a11f517 100644 --- a/desmume/src/fs-linux.c +++ b/desmume/src/fs-linux.c @@ -1,14 +1,48 @@ #include "fs.h" +#include +#include +#include +#include + void * FsReadFirst(const char * path, FsEntry * entry) { - return 0; + DIR * dir; + struct dirent * e; + + printf("reading %s\n", path); + dir = opendir(path); + if (!dir) + return NULL; + + e = readdir(dir); + if (!e) + return NULL; + + strcpy(entry->cFileName, e->d_name); + strncpy(entry->cAlternateFileName, e->d_name, 12); + entry->flags = 0; + + return dir; } int FsReadNext(void * search, FsEntry * entry) { - return 0; + struct dirent * e; + + e = readdir(search); + if (!e) + return 0; + + strcpy(entry->cFileName, e->d_name); + strncpy(entry->cAlternateFileName, e->d_name, 12); + entry->flags = 0; + + return 1; } void FsClose(void * search) { + DIR * dir = search; + + closedir(dir); } int FsError(void) {