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) {