diff options
| author | Daniel Stenberg <daniel@haxx.se> | 2002-05-07 11:35:03 +0000 |
|---|---|---|
| committer | Daniel Stenberg <daniel@haxx.se> | 2002-05-07 11:35:03 +0000 |
| commit | 159d448739e5237e47ca5936c063c1bce5799fd1 (patch) | |
| tree | 6e4664bf61676ec5660bbc026c46ac708f5bc1ec | |
| parent | 276f62bc6edb53363e98b3bc1a421adb286d6cf8 (diff) | |
| download | rockbox-159d448739e5237e47ca5936c063c1bce5799fd1.zip rockbox-159d448739e5237e47ca5936c063c1bce5799fd1.tar.gz rockbox-159d448739e5237e47ca5936c063c1bce5799fd1.tar.bz2 rockbox-159d448739e5237e47ca5936c063c1bce5799fd1.tar.xz | |
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
| -rw-r--r-- | uisimulator/x11/dir.h | 20 | ||||
| -rw-r--r-- | uisimulator/x11/io.c | 15 |
2 files changed, 32 insertions, 3 deletions
diff --git a/uisimulator/x11/dir.h b/uisimulator/x11/dir.h index c7d557b..3e83ce4 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 <sys/types.h> #include <dirent.h> -#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 2a94969..0452d65 100644 --- a/uisimulator/x11/io.c +++ b/uisimulator/x11/io.c @@ -1,5 +1,5 @@ -#include <dirent.h> +#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 */ |