summaryrefslogtreecommitdiff
path: root/uisimulator/common/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator/common/io.c')
-rw-r--r--uisimulator/common/io.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 52df94901b..185e46260c 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -252,19 +252,22 @@ static ssize_t io_trigger_and_wait(int cmd)
252 return result; 252 return result;
253} 253}
254 254
255#ifndef __PCTOOL__
255static const char *get_sim_rootdir() 256static const char *get_sim_rootdir()
256{ 257{
257 if (sim_root_dir != NULL) 258 if (sim_root_dir != NULL)
258 return sim_root_dir; 259 return sim_root_dir;
259 return SIMULATOR_DEFAULT_ROOT; 260 return SIMULATOR_DEFAULT_ROOT;
260} 261}
262#endif
261 263
262MYDIR *sim_opendir(const char *name) 264MYDIR *sim_opendir(const char *name)
263{ 265{
264 char buffer[MAX_PATH]; /* sufficiently big */
265 DIR_T *dir; 266 DIR_T *dir;
266 267
267#ifndef __PCTOOL__ 268#ifndef __PCTOOL__
269 char buffer[MAX_PATH]; /* sufficiently big */
270
268 if(name[0] == '/') 271 if(name[0] == '/')
269 { 272 {
270 snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name); 273 snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
@@ -277,7 +280,8 @@ MYDIR *sim_opendir(const char *name)
277 if(dir) { 280 if(dir) {
278 MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR)); 281 MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR));
279 my->dir = dir; 282 my->dir = dir;
280 my->name = (char *)strdup(name); 283 my->name = (char *)malloc(strlen(name)+1);
284 strcpy(my->name, name);
281 285
282 return my; 286 return my;
283 } 287 }
@@ -357,12 +361,10 @@ int sim_open(const char *name, int o)
357 name); 361 name);
358 return -1; 362 return -1;
359#else 363#else
360 if (num_openfiles < MAX_OPEN_FILES) 364 ret = OPEN(name, opts, 0666);
361 { 365 if (ret >= 0)
362 ret = OPEN(buffer, opts, 0666); 366 num_openfiles++;
363 if (ret >= 0) num_openfiles++; 367 return ret;
364 return ret;
365 }
366#endif 368#endif
367} 369}
368 370