1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Daniel Stenberg 2002-05-07 11:35:03 +00:00
parent 276f62bc6e
commit 159d448739
2 changed files with 32 additions and 3 deletions

View file

@ -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);

View file

@ -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 */