summaryrefslogtreecommitdiff
path: root/uisimulator/x11/io.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-05-07 12:06:32 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-05-07 12:06:32 +0000
commit27dfc7c14ea181d538446138801537a713601ee6 (patch)
treeda820bcc5ef811c9d3a370e80f6afa0a571a9897 /uisimulator/x11/io.c
parent8ae29ff4b2552f6c91c9a1b55d82fb9d8452bf7d (diff)
downloadrockbox-27dfc7c14ea181d538446138801537a713601ee6.tar.gz
rockbox-27dfc7c14ea181d538446138801537a713601ee6.zip
extended the wrapper layer, we can't depend on much in the "real" dirent
struct since it differs too much between unixes. d_name is there, the rest we get with stat() calls to simulate the target dirent properly git-svn-id: svn://svn.rockbox.org/rockbox/trunk@492 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/x11/io.c')
-rw-r--r--uisimulator/x11/io.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/uisimulator/x11/io.c b/uisimulator/x11/io.c
index 0452d65ae8..726bfa26a2 100644
--- a/uisimulator/x11/io.c
+++ b/uisimulator/x11/io.c
@@ -1,31 +1,55 @@
1 1
2#include <sys/stat.h>
2#include "dir.h" 3#include "dir.h"
3 4
4#define SIMULATOR_ARCHOS_ROOT "archos" 5#undef DIR
5 6
6DIR *x11_opendir(char *name) 7MYDIR *x11_opendir(char *name)
7{ 8{
8 char buffer[256]; /* sufficiently big */ 9 char buffer[256]; /* sufficiently big */
10 MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR));
9 11
10 if(name[0] == '/') { 12 if(name[0] == '/') {
11 sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); 13 sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
12 return opendir(buffer); 14 my->dir=(DIR *)opendir(buffer);
13 } 15 }
14 return opendir(name); 16 else
17 my->dir=(DIR *)opendir(name);
18
19 my->name = (char *)strdup(name);
20
21 return my;
15} 22}
16 23
17struct dirent *x11_readdir(DIR *dir) 24struct dirent *x11_readdir(MYDIR *dir)
18{ 25{
26 char buffer[512]; /* sufficiently big */
19 static struct dirent secret; 27 static struct dirent secret;
28 struct stat s;
20 29
21 struct x11_dirent *x11 = (readdir)(dir); 30 struct x11_dirent *x11 = (readdir)(dir->dir);
22 31
23 strcpy(secret.d_name, x11->d_name); 32 strcpy(secret.d_name, x11->d_name);
24 secret.attribute = (x11->d_type == DT_DIR)?ATTR_DIRECTORY:0; 33
34 /* build file name */
35 sprintf(buffer, SIMULATOR_ARCHOS_ROOT "%s/%s",
36 dir->name, x11->d_name);
37 stat(buffer, &s); /* get info */
38
39 secret.attribute = S_ISDIR(s.st_mode)?ATTR_DIRECTORY:0;
40 secret.size = s.st_size;
25 41
26 return &secret; 42 return &secret;
27} 43}
28 44
45void x11_closedir(MYDIR *dir)
46{
47 free(dir->name);
48 (closedir)(dir->dir);
49
50 free(dir);
51}
52
29 53
30int x11_open(char *name, int opts) 54int x11_open(char *name, int opts)
31{ 55{