mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 10:37:38 -04:00
application: Remove trailing slashes from the input in opendir().
This is needed for readdir() and dir_get_info() to work properly because they depend on hash/path matching. Change-Id: Ibd23def10eebabd76cdddac2739a5274159e88a9
This commit is contained in:
parent
5fd8dd1321
commit
731072de7a
1 changed files with 8 additions and 4 deletions
|
@ -341,10 +341,14 @@ DIR* app_opendir(const char *_name)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
struct __dir *this = (struct __dir*)buf;
|
struct __dir *this = (struct __dir*)buf;
|
||||||
/* definitely fits due to strlen() */
|
/* carefully remove any trailing slash from the input, so that
|
||||||
strcpy(this->path, name);
|
* hash/path matching in readdir() works properly */
|
||||||
|
while (name[name_len-1] == '/')
|
||||||
this->dir = opendir(name);
|
name_len -= 1;
|
||||||
|
/* strcpy cannot be used because of trailing slashes */
|
||||||
|
memcpy(this->path, name, name_len);
|
||||||
|
this->path[name_len] = 0;
|
||||||
|
this->dir = opendir(this->path);
|
||||||
|
|
||||||
if (!this->dir)
|
if (!this->dir)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue