forked from len0rd/rockbox
The pathname argument for open() is declared const, so copy it has to be copied
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4894 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
97d1d15bd8
commit
f68e13c5b4
1 changed files with 11 additions and 7 deletions
|
@ -63,6 +63,7 @@ int open(const char* pathname, int flags)
|
||||||
DIR* dir;
|
DIR* dir;
|
||||||
struct dirent* entry;
|
struct dirent* entry;
|
||||||
int fd;
|
int fd;
|
||||||
|
char pathnamecopy[MAX_PATH];
|
||||||
char* name;
|
char* name;
|
||||||
struct filedesc* file = NULL;
|
struct filedesc* file = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -98,17 +99,20 @@ int open(const char* pathname, int flags)
|
||||||
}
|
}
|
||||||
file->busy = true;
|
file->busy = true;
|
||||||
|
|
||||||
|
strncpy(pathnamecopy,pathname,sizeof(pathnamecopy));
|
||||||
|
pathnamecopy[sizeof(pathnamecopy)-1] = 0;
|
||||||
|
|
||||||
/* locate filename */
|
/* locate filename */
|
||||||
name=strrchr(pathname+1,'/');
|
name=strrchr(pathnamecopy+1,'/');
|
||||||
if ( name ) {
|
if ( name ) {
|
||||||
*name = 0;
|
*name = 0;
|
||||||
dir = opendir((char*)pathname);
|
dir = opendir(pathnamecopy);
|
||||||
*name = '/';
|
*name = '/';
|
||||||
name++;
|
name++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dir = opendir("/");
|
dir = opendir("/");
|
||||||
name = (char*)pathname+1;
|
name = pathnamecopy+1;
|
||||||
}
|
}
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
DEBUGF("Failed opening dir\n");
|
DEBUGF("Failed opening dir\n");
|
||||||
|
@ -144,7 +148,7 @@ int open(const char* pathname, int flags)
|
||||||
&(file->fatfile),
|
&(file->fatfile),
|
||||||
&(dir->fatdir));
|
&(dir->fatdir));
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
DEBUGF("Couldn't create %s in %s\n",name,pathname);
|
DEBUGF("Couldn't create %s in %s\n",name,pathnamecopy);
|
||||||
errno = EIO;
|
errno = EIO;
|
||||||
file->busy = false;
|
file->busy = false;
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
@ -154,7 +158,7 @@ int open(const char* pathname, int flags)
|
||||||
file->attr = 0;
|
file->attr = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUGF("Couldn't find %s in %s\n",name,pathname);
|
DEBUGF("Couldn't find %s in %s\n",name,pathnamecopy);
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
file->busy = false;
|
file->busy = false;
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue