1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Steve Bavin 2007-11-08 10:15:44 +00:00
parent d67c29302a
commit 9e05cc537b
2 changed files with 57 additions and 22 deletions

View file

@ -139,7 +139,9 @@ void dircache_remove(const char *name);
void dircache_rename(const char *oldpath, const char *newpath); void dircache_rename(const char *oldpath, const char *newpath);
#endif #endif
#define SIMULATOR_ARCHOS_ROOT "archos"
#define SIMULATOR_DEFAULT_ROOT "archos"
extern const char *sim_root_dir;
static int num_openfiles = 0; static int num_openfiles = 0;
@ -317,6 +319,13 @@ static void io_trigger_and_wait(int cmd)
yield(); yield();
} }
static const char *get_sim_rootdir()
{
if (sim_root_dir != NULL)
return sim_root_dir;
return SIMULATOR_DEFAULT_ROOT;
}
MYDIR *sim_opendir(const char *name) MYDIR *sim_opendir(const char *name)
{ {
char buffer[MAX_PATH]; /* sufficiently big */ char buffer[MAX_PATH]; /* sufficiently big */
@ -325,7 +334,7 @@ MYDIR *sim_opendir(const char *name)
#ifndef __PCTOOL__ #ifndef __PCTOOL__
if(name[0] == '/') if(name[0] == '/')
{ {
snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
dir=(DIR_T *)OPENDIR(buffer); dir=(DIR_T *)OPENDIR(buffer);
} }
else else
@ -360,8 +369,8 @@ struct sim_dirent *sim_readdir(MYDIR *dir)
#ifdef __PCTOOL__ #ifdef __PCTOOL__
snprintf(buffer, sizeof(buffer), "%s/%s", dir->name, secret.d_name); snprintf(buffer, sizeof(buffer), "%s/%s", dir->name, secret.d_name);
#else #else
snprintf(buffer, sizeof(buffer), SIMULATOR_ARCHOS_ROOT "%s/%s", snprintf(buffer, sizeof(buffer), "%s/%s/%s",
dir->name, secret.d_name); get_sim_rootdir(), dir->name, secret.d_name);
#endif #endif
STAT(buffer, &s); /* get info */ STAT(buffer, &s); /* get info */
@ -400,7 +409,7 @@ int sim_open(const char *name, int o)
#ifndef __PCTOOL__ #ifndef __PCTOOL__
if(name[0] == '/') if(name[0] == '/')
{ {
snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
debugf("We open the real file '%s'\n", buffer); debugf("We open the real file '%s'\n", buffer);
if (num_openfiles < MAX_OPEN_FILES) if (num_openfiles < MAX_OPEN_FILES)
@ -438,7 +447,7 @@ int sim_creat(const char *name)
char buffer[MAX_PATH]; /* sufficiently big */ char buffer[MAX_PATH]; /* sufficiently big */
if(name[0] == '/') if(name[0] == '/')
{ {
snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
debugf("We create the real file '%s'\n", buffer); debugf("We create the real file '%s'\n", buffer);
return OPEN(buffer, O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, 0666); return OPEN(buffer, O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, 0666);
@ -496,7 +505,7 @@ int sim_mkdir(const char *name)
#else #else
char buffer[MAX_PATH]; /* sufficiently big */ char buffer[MAX_PATH]; /* sufficiently big */
snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
debugf("We create the real directory '%s'\n", buffer); debugf("We create the real directory '%s'\n", buffer);
return MKDIR(buffer, 0777); return MKDIR(buffer, 0777);
@ -511,7 +520,7 @@ int sim_rmdir(const char *name)
char buffer[MAX_PATH]; /* sufficiently big */ char buffer[MAX_PATH]; /* sufficiently big */
if(name[0] == '/') if(name[0] == '/')
{ {
snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
debugf("We remove the real directory '%s'\n", buffer); debugf("We remove the real directory '%s'\n", buffer);
return RMDIR(buffer); return RMDIR(buffer);
@ -532,7 +541,7 @@ int sim_remove(const char *name)
#endif #endif
if(name[0] == '/') { if(name[0] == '/') {
snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
debugf("We remove the real file '%s'\n", buffer); debugf("We remove the real file '%s'\n", buffer);
return REMOVE(buffer); return REMOVE(buffer);
@ -554,9 +563,9 @@ int sim_rename(const char *oldpath, const char* newpath)
#endif #endif
if(oldpath[0] == '/') { if(oldpath[0] == '/') {
snprintf(buffer1, sizeof(buffer1), "%s%s", SIMULATOR_ARCHOS_ROOT, snprintf(buffer1, sizeof(buffer1), "%s%s", get_sim_rootdir(),
oldpath); oldpath);
snprintf(buffer2, sizeof(buffer2), "%s%s", SIMULATOR_ARCHOS_ROOT, snprintf(buffer2, sizeof(buffer2), "%s%s", get_sim_rootdir(),
newpath); newpath);
debugf("We rename the real file '%s' to '%s'\n", buffer1, buffer2); debugf("We rename the real file '%s' to '%s'\n", buffer1, buffer2);

View file

@ -56,6 +56,7 @@ SDL_TimerID tick_timer_id;
bool lcd_display_redraw = true; /* Used for player simulator */ bool lcd_display_redraw = true; /* Used for player simulator */
char having_new_lcd = true; /* Used for player simulator */ char having_new_lcd = true; /* Used for player simulator */
bool sim_alarm_wakeup = false; bool sim_alarm_wakeup = false;
const char *sim_root_dir = NULL;
bool debug_audio = false; bool debug_audio = false;
@ -195,40 +196,65 @@ bool gui_shutdown(void)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
if (argc >= 1) { if (argc >= 1)
{
int x; int x;
for (x = 1; x < argc; x++) { for (x = 1; x < argc; x++)
if (!strcmp("--debugaudio", argv[x])) { {
if (!strcmp("--debugaudio", argv[x]))
{
debug_audio = true; debug_audio = true;
printf("Writing debug audio file.\n"); printf("Writing debug audio file.\n");
} else if (!strcmp("--debugwps", argv[x])) { }
else if (!strcmp("--debugwps", argv[x]))
{
debug_wps = true; debug_wps = true;
printf("WPS debug mode enabled.\n"); printf("WPS debug mode enabled.\n");
} else if (!strcmp("--background", argv[x])) { }
else if (!strcmp("--background", argv[x]))
{
background = true; background = true;
printf("Using background image.\n"); printf("Using background image.\n");
} else if (!strcmp("--old_lcd", argv[x])) { }
else if (!strcmp("--old_lcd", argv[x]))
{
having_new_lcd = false; having_new_lcd = false;
printf("Using old LCD layout.\n"); printf("Using old LCD layout.\n");
} else if (!strcmp("--zoom", argv[x])) { }
else if (!strcmp("--zoom", argv[x]))
{
x++; x++;
if(x < argc) if(x < argc)
display_zoom=atoi(argv[x]); display_zoom=atoi(argv[x]);
else else
display_zoom = 2; display_zoom = 2;
printf("Window zoom is %d\n", display_zoom); printf("Window zoom is %d\n", display_zoom);
} else if (!strcmp("--alarm", argv[x])) { }
else if (!strcmp("--alarm", argv[x]))
{
sim_alarm_wakeup = true; sim_alarm_wakeup = true;
printf("Simulating alarm wakeup.\n"); printf("Simulating alarm wakeup.\n");
} else { }
else if (!strcmp("--root", argv[x]))
{
x++;
if (x < argc)
{
sim_root_dir = argv[x];
printf("Root directory: %s\n", sim_root_dir);
}
}
else
{
printf("rockboxui\n"); printf("rockboxui\n");
printf("Arguments:\n"); printf("Arguments:\n");
printf(" --debugaudio \t Write raw PCM data to audiodebug.raw\n"); printf(" --debugaudio \t Write raw PCM data to audiodebug.raw\n");
printf(" --debugwps \t Print advanced WPS debug info\n"); printf(" --debugwps \t Print advanced WPS debug info\n");
printf(" --background \t Use background image of hardware\n"); printf(" --background \t Use background image of hardware\n");
printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n"); printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n");
printf(" --zoom [VAL]\t window zoom (will disable backgrounds)\n"); printf(" --zoom [VAL]\t Window zoom (will disable backgrounds)\n");
printf(" --alarm \t Simulate a wakup-up on Alarm\n"); printf(" --alarm \t Simulate a wake-up on alarm\n");
printf(" --root [DIR]\t Set root directory\n");
exit(0); exit(0);
} }
} }