summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-05-10 06:54:33 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-05-10 06:54:33 +0000
commite078eddff98e54e11dc3d59b248073d434d5da8b (patch)
tree622cd1ba01aa6ee7bdd2bc630a2a2763c29c5eb3
parent59dd4363a8156ecc3d1365b46aedcf900552d28c (diff)
downloadrockbox-e078eddff98e54e11dc3d59b248073d434d5da8b.tar.gz
rockbox-e078eddff98e54e11dc3d59b248073d434d5da8b.zip
x11_opendir() now fails properly in case the dir doesn't exist
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@537 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--uisimulator/x11/io.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/uisimulator/x11/io.c b/uisimulator/x11/io.c
index 1e2ebd76c0..17a0c94b70 100644
--- a/uisimulator/x11/io.c
+++ b/uisimulator/x11/io.c
@@ -19,18 +19,24 @@ typedef struct mydir MYDIR;
MYDIR *x11_opendir(char *name)
{
char buffer[256]; /* sufficiently big */
- MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR));
+ DIR *dir;
if(name[0] == '/') {
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
- my->dir=(DIR *)opendir(buffer);
+ dir=(DIR *)opendir(buffer);
}
else
- my->dir=(DIR *)opendir(name);
-
- my->name = (char *)strdup(name);
+ dir=(DIR *)opendir(name);
+
+ if(dir) {
+ MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR));
+ my->dir = dir;
+ my->name = (char *)strdup(name);
- return my;
+ return my;
+ }
+ /* failed open, return NULL */
+ return (MYDIR *)0;
}
struct x11_dirent *x11_readdir(MYDIR *dir)