summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--uisimulator/common/io.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 950ce6e4ae..d6c197677b 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -258,31 +258,31 @@ static ssize_t io_trigger_and_wait(int cmd)
258} 258}
259 259
260#ifndef __PCTOOL__ 260#ifndef __PCTOOL__
261static const char *get_sim_rootdir() 261static const char *get_sim_pathname(const char *name)
262{ 262{
263 if (sim_root_dir != NULL) 263 static char buffer[MAX_PATH]; /* sufficiently big */
264 return sim_root_dir; 264
265 return SIMULATOR_DEFAULT_ROOT; 265 if(name[0] == '/')
266 {
267 snprintf(buffer, sizeof(buffer), "%s%s",
268 sim_root_dir != NULL ? sim_root_dir : SIMULATOR_DEFAULT_ROOT, name);
269 return buffer;
270 }
271 DEBUGF("warning, filename lacks leading slash: %s\n", name);
272 return name;
266} 273}
274#else
275#define get_sim_pathname(name) name
267#endif 276#endif
268 277
269MYDIR *sim_opendir(const char *name) 278MYDIR *sim_opendir(const char *name)
270{ 279{
271 DIR_T *dir; 280 DIR_T *dir;
272 281
273#ifndef __PCTOOL__ 282 dir = (DIR_T *) OPENDIR(get_sim_pathname(name));
274 char buffer[MAX_PATH]; /* sufficiently big */
275 283
276 if(name[0] == '/') 284 if (dir)
277 { 285 {
278 snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
279 dir=(DIR_T *)OPENDIR(buffer);
280 }
281 else
282#endif
283 dir=(DIR_T *)OPENDIR(name);
284
285 if(dir) {
286 MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR)); 286 MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR));
287 my->dir = dir; 287 my->dir = dir;
288 my->name = (char *)malloc(strlen(name)+1); 288 my->name = (char *)malloc(strlen(name)+1);
@@ -308,12 +308,8 @@ struct sim_dirent *sim_readdir(MYDIR *dir)
308 strcpy((char *)secret.d_name, OS_TO_UTF8(x11->d_name)); 308 strcpy((char *)secret.d_name, OS_TO_UTF8(x11->d_name));
309 309
310 /* build file name */ 310 /* build file name */
311#ifdef __PCTOOL__ 311 snprintf(buffer, sizeof(buffer), "%s/%s",
312 snprintf(buffer, sizeof(buffer), "%s/%s", dir->name, secret.d_name); 312 get_sim_pathname(dir->name), secret.d_name);
313#else
314 snprintf(buffer, sizeof(buffer), "%s/%s/%s",
315 get_sim_rootdir(), dir->name, secret.d_name);
316#endif
317 STAT(buffer, &s); /* get info */ 313 STAT(buffer, &s); /* get info */
318 314
319#define ATTR_DIRECTORY 0x10 315#define ATTR_DIRECTORY 0x10
@@ -632,7 +628,8 @@ void *sim_codec_load_ram(char* codecptr, int size, void **pd)
632 628
633 /* Now load the library. */ 629 /* Now load the library. */
634 *pd = dlopen(path, RTLD_NOW); 630 *pd = dlopen(path, RTLD_NOW);
635 if (*pd == NULL) { 631 if (*pd == NULL)
632 {
636 DEBUGF("failed to load %s\n", path); 633 DEBUGF("failed to load %s\n", path);
637#ifdef WIN32 634#ifdef WIN32
638 FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, 635 FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,