forked from len0rd/rockbox
FS#9964 - Fix simulator file i/o when the --root option is used.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20132 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
5c1c43f39b
commit
6eea66fbc1
1 changed files with 19 additions and 22 deletions
|
|
@ -258,31 +258,31 @@ static ssize_t io_trigger_and_wait(int cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __PCTOOL__
|
#ifndef __PCTOOL__
|
||||||
static const char *get_sim_rootdir()
|
static const char *get_sim_pathname(const char *name)
|
||||||
{
|
{
|
||||||
if (sim_root_dir != NULL)
|
static char buffer[MAX_PATH]; /* sufficiently big */
|
||||||
return sim_root_dir;
|
|
||||||
return SIMULATOR_DEFAULT_ROOT;
|
if(name[0] == '/')
|
||||||
|
{
|
||||||
|
snprintf(buffer, sizeof(buffer), "%s%s",
|
||||||
|
sim_root_dir != NULL ? sim_root_dir : SIMULATOR_DEFAULT_ROOT, name);
|
||||||
|
return buffer;
|
||||||
}
|
}
|
||||||
|
DEBUGF("warning, filename lacks leading slash: %s\n", name);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define get_sim_pathname(name) name
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MYDIR *sim_opendir(const char *name)
|
MYDIR *sim_opendir(const char *name)
|
||||||
{
|
{
|
||||||
DIR_T *dir;
|
DIR_T *dir;
|
||||||
|
|
||||||
#ifndef __PCTOOL__
|
dir = (DIR_T *) OPENDIR(get_sim_pathname(name));
|
||||||
char buffer[MAX_PATH]; /* sufficiently big */
|
|
||||||
|
|
||||||
if(name[0] == '/')
|
if (dir)
|
||||||
{
|
{
|
||||||
snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
|
|
||||||
dir=(DIR_T *)OPENDIR(buffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
dir=(DIR_T *)OPENDIR(name);
|
|
||||||
|
|
||||||
if(dir) {
|
|
||||||
MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR));
|
MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR));
|
||||||
my->dir = dir;
|
my->dir = dir;
|
||||||
my->name = (char *)malloc(strlen(name)+1);
|
my->name = (char *)malloc(strlen(name)+1);
|
||||||
|
|
@ -308,12 +308,8 @@ struct sim_dirent *sim_readdir(MYDIR *dir)
|
||||||
strcpy((char *)secret.d_name, OS_TO_UTF8(x11->d_name));
|
strcpy((char *)secret.d_name, OS_TO_UTF8(x11->d_name));
|
||||||
|
|
||||||
/* build file name */
|
/* build file name */
|
||||||
#ifdef __PCTOOL__
|
snprintf(buffer, sizeof(buffer), "%s/%s",
|
||||||
snprintf(buffer, sizeof(buffer), "%s/%s", dir->name, secret.d_name);
|
get_sim_pathname(dir->name), secret.d_name);
|
||||||
#else
|
|
||||||
snprintf(buffer, sizeof(buffer), "%s/%s/%s",
|
|
||||||
get_sim_rootdir(), dir->name, secret.d_name);
|
|
||||||
#endif
|
|
||||||
STAT(buffer, &s); /* get info */
|
STAT(buffer, &s); /* get info */
|
||||||
|
|
||||||
#define ATTR_DIRECTORY 0x10
|
#define ATTR_DIRECTORY 0x10
|
||||||
|
|
@ -632,7 +628,8 @@ void *sim_codec_load_ram(char* codecptr, int size, void **pd)
|
||||||
|
|
||||||
/* Now load the library. */
|
/* Now load the library. */
|
||||||
*pd = dlopen(path, RTLD_NOW);
|
*pd = dlopen(path, RTLD_NOW);
|
||||||
if (*pd == NULL) {
|
if (*pd == NULL)
|
||||||
|
{
|
||||||
DEBUGF("failed to load %s\n", path);
|
DEBUGF("failed to load %s\n", path);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
|
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue