From 159d448739e5237e47ca5936c063c1bce5799fd1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 7 May 2002 11:35:03 +0000 Subject: readdir() wrapper for proper dirent struct emulation in target code git-svn-id: svn://svn.rockbox.org/rockbox/trunk@488 a1c6a512-1295-4272-9138-f99709370657 --- uisimulator/x11/dir.h | 20 ++++++++++++++++++-- uisimulator/x11/io.c | 15 ++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) (limited to 'uisimulator/x11') diff --git a/uisimulator/x11/dir.h b/uisimulator/x11/dir.h index c7d557b475..3e83ce44b4 100644 --- a/uisimulator/x11/dir.h +++ b/uisimulator/x11/dir.h @@ -17,10 +17,26 @@ * ****************************************************************************/ +#define dirent x11_dirent +#define readdir(x) x11_readdir(x) +#define opendir(x) x11_opendir(x) + +/* + * The defines above should let us use the readdir() and opendir() in target + * code just as they're defined to work in target. They will then call our + * x11_* versions of the functions that'll work as wrappers for the actual + * host functions. + */ + #include #include -#define opendir(x) x11_opendir(x) +#undef dirent + + +#define DIRFUNCTIONS_DEFINED /* prevent those prototypes */ -#define DIRENT_DEFINED /* prevent it from getting defined again */ #include "../../firmware/common/dir.h" + +extern DIR *x11_opendir(char *name); + diff --git a/uisimulator/x11/io.c b/uisimulator/x11/io.c index 2a94969ce3..0452d65ae8 100644 --- a/uisimulator/x11/io.c +++ b/uisimulator/x11/io.c @@ -1,5 +1,5 @@ -#include +#include "dir.h" #define SIMULATOR_ARCHOS_ROOT "archos" @@ -14,6 +14,19 @@ DIR *x11_opendir(char *name) return opendir(name); } +struct dirent *x11_readdir(DIR *dir) +{ + static struct dirent secret; + + struct x11_dirent *x11 = (readdir)(dir); + + strcpy(secret.d_name, x11->d_name); + secret.attribute = (x11->d_type == DT_DIR)?ATTR_DIRECTORY:0; + + return &secret; +} + + int x11_open(char *name, int opts) { char buffer[256]; /* sufficiently big */ -- cgit v1.2.3