mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-10 05:35:20 -05:00
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:
parent
276f62bc6e
commit
159d448739
2 changed files with 32 additions and 3 deletions
|
|
@ -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 <sys/types.h>
|
||||||
#include <dirent.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"
|
#include "../../firmware/common/dir.h"
|
||||||
|
|
||||||
|
extern DIR *x11_opendir(char *name);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
#include <dirent.h>
|
#include "dir.h"
|
||||||
|
|
||||||
#define SIMULATOR_ARCHOS_ROOT "archos"
|
#define SIMULATOR_ARCHOS_ROOT "archos"
|
||||||
|
|
||||||
|
|
@ -14,6 +14,19 @@ DIR *x11_opendir(char *name)
|
||||||
return opendir(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)
|
int x11_open(char *name, int opts)
|
||||||
{
|
{
|
||||||
char buffer[256]; /* sufficiently big */
|
char buffer[256]; /* sufficiently big */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue