diff options
author | Steve Bavin <pondlife@pondlife.me> | 2007-11-08 10:15:44 +0000 |
---|---|---|
committer | Steve Bavin <pondlife@pondlife.me> | 2007-11-08 10:15:44 +0000 |
commit | 9e05cc537baf69ab636d4ba5b8c4b1265e3729ee (patch) | |
tree | ddb533f3de5bbd9e538361e5fe79662b88c6564c /uisimulator/common | |
parent | d67c29302aeb3e4c4fbbadd0caeb5ce8209d76d2 (diff) | |
download | rockbox-9e05cc537baf69ab636d4ba5b8c4b1265e3729ee.tar.gz rockbox-9e05cc537baf69ab636d4ba5b8c4b1265e3729ee.zip |
Add --root option to allow overriding of simulator root menu.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15526 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/common')
-rw-r--r-- | uisimulator/common/io.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c index 1e0c25bad1..fff12a0832 100644 --- a/uisimulator/common/io.c +++ b/uisimulator/common/io.c | |||
@@ -139,7 +139,9 @@ void dircache_remove(const char *name); | |||
139 | void dircache_rename(const char *oldpath, const char *newpath); | 139 | void dircache_rename(const char *oldpath, const char *newpath); |
140 | #endif | 140 | #endif |
141 | 141 | ||
142 | #define SIMULATOR_ARCHOS_ROOT "archos" | 142 | |
143 | #define SIMULATOR_DEFAULT_ROOT "archos" | ||
144 | extern const char *sim_root_dir; | ||
143 | 145 | ||
144 | static int num_openfiles = 0; | 146 | static int num_openfiles = 0; |
145 | 147 | ||
@@ -317,6 +319,13 @@ static void io_trigger_and_wait(int cmd) | |||
317 | yield(); | 319 | yield(); |
318 | } | 320 | } |
319 | 321 | ||
322 | static const char *get_sim_rootdir() | ||
323 | { | ||
324 | if (sim_root_dir != NULL) | ||
325 | return sim_root_dir; | ||
326 | return SIMULATOR_DEFAULT_ROOT; | ||
327 | } | ||
328 | |||
320 | MYDIR *sim_opendir(const char *name) | 329 | MYDIR *sim_opendir(const char *name) |
321 | { | 330 | { |
322 | char buffer[MAX_PATH]; /* sufficiently big */ | 331 | char buffer[MAX_PATH]; /* sufficiently big */ |
@@ -325,7 +334,7 @@ MYDIR *sim_opendir(const char *name) | |||
325 | #ifndef __PCTOOL__ | 334 | #ifndef __PCTOOL__ |
326 | if(name[0] == '/') | 335 | if(name[0] == '/') |
327 | { | 336 | { |
328 | snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); | 337 | snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name); |
329 | dir=(DIR_T *)OPENDIR(buffer); | 338 | dir=(DIR_T *)OPENDIR(buffer); |
330 | } | 339 | } |
331 | else | 340 | else |
@@ -360,8 +369,8 @@ struct sim_dirent *sim_readdir(MYDIR *dir) | |||
360 | #ifdef __PCTOOL__ | 369 | #ifdef __PCTOOL__ |
361 | snprintf(buffer, sizeof(buffer), "%s/%s", dir->name, secret.d_name); | 370 | snprintf(buffer, sizeof(buffer), "%s/%s", dir->name, secret.d_name); |
362 | #else | 371 | #else |
363 | snprintf(buffer, sizeof(buffer), SIMULATOR_ARCHOS_ROOT "%s/%s", | 372 | snprintf(buffer, sizeof(buffer), "%s/%s/%s", |
364 | dir->name, secret.d_name); | 373 | get_sim_rootdir(), dir->name, secret.d_name); |
365 | #endif | 374 | #endif |
366 | STAT(buffer, &s); /* get info */ | 375 | STAT(buffer, &s); /* get info */ |
367 | 376 | ||
@@ -400,7 +409,7 @@ int sim_open(const char *name, int o) | |||
400 | #ifndef __PCTOOL__ | 409 | #ifndef __PCTOOL__ |
401 | if(name[0] == '/') | 410 | if(name[0] == '/') |
402 | { | 411 | { |
403 | snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); | 412 | snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name); |
404 | 413 | ||
405 | debugf("We open the real file '%s'\n", buffer); | 414 | debugf("We open the real file '%s'\n", buffer); |
406 | if (num_openfiles < MAX_OPEN_FILES) | 415 | if (num_openfiles < MAX_OPEN_FILES) |
@@ -438,7 +447,7 @@ int sim_creat(const char *name) | |||
438 | char buffer[MAX_PATH]; /* sufficiently big */ | 447 | char buffer[MAX_PATH]; /* sufficiently big */ |
439 | if(name[0] == '/') | 448 | if(name[0] == '/') |
440 | { | 449 | { |
441 | snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); | 450 | snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name); |
442 | 451 | ||
443 | debugf("We create the real file '%s'\n", buffer); | 452 | debugf("We create the real file '%s'\n", buffer); |
444 | return OPEN(buffer, O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, 0666); | 453 | return OPEN(buffer, O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, 0666); |
@@ -496,7 +505,7 @@ int sim_mkdir(const char *name) | |||
496 | #else | 505 | #else |
497 | char buffer[MAX_PATH]; /* sufficiently big */ | 506 | char buffer[MAX_PATH]; /* sufficiently big */ |
498 | 507 | ||
499 | snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); | 508 | snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name); |
500 | 509 | ||
501 | debugf("We create the real directory '%s'\n", buffer); | 510 | debugf("We create the real directory '%s'\n", buffer); |
502 | return MKDIR(buffer, 0777); | 511 | return MKDIR(buffer, 0777); |
@@ -511,7 +520,7 @@ int sim_rmdir(const char *name) | |||
511 | char buffer[MAX_PATH]; /* sufficiently big */ | 520 | char buffer[MAX_PATH]; /* sufficiently big */ |
512 | if(name[0] == '/') | 521 | if(name[0] == '/') |
513 | { | 522 | { |
514 | snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); | 523 | snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name); |
515 | 524 | ||
516 | debugf("We remove the real directory '%s'\n", buffer); | 525 | debugf("We remove the real directory '%s'\n", buffer); |
517 | return RMDIR(buffer); | 526 | return RMDIR(buffer); |
@@ -532,7 +541,7 @@ int sim_remove(const char *name) | |||
532 | #endif | 541 | #endif |
533 | 542 | ||
534 | if(name[0] == '/') { | 543 | if(name[0] == '/') { |
535 | snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); | 544 | snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name); |
536 | 545 | ||
537 | debugf("We remove the real file '%s'\n", buffer); | 546 | debugf("We remove the real file '%s'\n", buffer); |
538 | return REMOVE(buffer); | 547 | return REMOVE(buffer); |
@@ -554,9 +563,9 @@ int sim_rename(const char *oldpath, const char* newpath) | |||
554 | #endif | 563 | #endif |
555 | 564 | ||
556 | if(oldpath[0] == '/') { | 565 | if(oldpath[0] == '/') { |
557 | snprintf(buffer1, sizeof(buffer1), "%s%s", SIMULATOR_ARCHOS_ROOT, | 566 | snprintf(buffer1, sizeof(buffer1), "%s%s", get_sim_rootdir(), |
558 | oldpath); | 567 | oldpath); |
559 | snprintf(buffer2, sizeof(buffer2), "%s%s", SIMULATOR_ARCHOS_ROOT, | 568 | snprintf(buffer2, sizeof(buffer2), "%s%s", get_sim_rootdir(), |
560 | newpath); | 569 | newpath); |
561 | 570 | ||
562 | debugf("We rename the real file '%s' to '%s'\n", buffer1, buffer2); | 571 | debugf("We rename the real file '%s' to '%s'\n", buffer1, buffer2); |