summaryrefslogtreecommitdiff
path: root/uisimulator
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/x11/dir.h20
-rw-r--r--uisimulator/x11/io.c15
2 files changed, 32 insertions, 3 deletions
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 @@
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19 19
20#define dirent x11_dirent
21#define readdir(x) x11_readdir(x)
22#define opendir(x) x11_opendir(x)
23
24/*
25 * The defines above should let us use the readdir() and opendir() in target
26 * code just as they're defined to work in target. They will then call our
27 * x11_* versions of the functions that'll work as wrappers for the actual
28 * host functions.
29 */
30
20#include <sys/types.h> 31#include <sys/types.h>
21#include <dirent.h> 32#include <dirent.h>
22 33
23#define opendir(x) x11_opendir(x) 34#undef dirent
35
36
37#define DIRFUNCTIONS_DEFINED /* prevent those prototypes */
24 38
25#define DIRENT_DEFINED /* prevent it from getting defined again */
26#include "../../firmware/common/dir.h" 39#include "../../firmware/common/dir.h"
40
41extern DIR *x11_opendir(char *name);
42
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 @@
1 1
2#include <dirent.h> 2#include "dir.h"
3 3
4#define SIMULATOR_ARCHOS_ROOT "archos" 4#define SIMULATOR_ARCHOS_ROOT "archos"
5 5
@@ -14,6 +14,19 @@ DIR *x11_opendir(char *name)
14 return opendir(name); 14 return opendir(name);
15} 15}
16 16
17struct dirent *x11_readdir(DIR *dir)
18{
19 static struct dirent secret;
20
21 struct x11_dirent *x11 = (readdir)(dir);
22
23 strcpy(secret.d_name, x11->d_name);
24 secret.attribute = (x11->d_type == DT_DIR)?ATTR_DIRECTORY:0;
25
26 return &secret;
27}
28
29
17int x11_open(char *name, int opts) 30int x11_open(char *name, int opts)
18{ 31{
19 char buffer[256]; /* sufficiently big */ 32 char buffer[256]; /* sufficiently big */