mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Optimised new file association handling. Fixed NULL pointer accesses. Const policed.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7459 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
70542d7a0c
commit
ac50839423
3 changed files with 38 additions and 33 deletions
|
@ -209,18 +209,20 @@ bool filetype_supported(int attr)
|
|||
}
|
||||
|
||||
/* get the "dynamic" attribute for an extension */
|
||||
int filetype_get_attr(char* name)
|
||||
int filetype_get_attr(const char* name)
|
||||
{
|
||||
int i;
|
||||
char *cp;
|
||||
const char *cp = strrchr(name,'.');
|
||||
|
||||
if (!cp) /* no extension? -> can't be a supported type */
|
||||
return 0;
|
||||
cp++;
|
||||
|
||||
for (i=0; i < cnt_exttypes; i++)
|
||||
{
|
||||
if (exttypes[i].extension)
|
||||
{
|
||||
cp=strrchr(name,'.');
|
||||
if (cp) cp++;
|
||||
if ((!strcasecmp(cp,exttypes[i].extension)) && (cp))
|
||||
if (!strcasecmp(cp,exttypes[i].extension))
|
||||
{
|
||||
return ((((unsigned long)exttypes[i].type -
|
||||
(unsigned long)&filetypes[0]) /
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <tree.h>
|
||||
#include <menu.h>
|
||||
|
||||
int filetype_get_attr(char*);
|
||||
int filetype_get_attr(const char*);
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
const char* filetype_get_icon(int);
|
||||
#else
|
||||
|
|
11
apps/tree.c
11
apps/tree.c
|
@ -1376,14 +1376,15 @@ static bool add_dir(char* dirname, int len, int fd)
|
|||
else {
|
||||
int x = strlen(entry->d_name);
|
||||
unsigned int i;
|
||||
char *cp;
|
||||
char *cp = strrchr(entry->d_name,'.');
|
||||
|
||||
if (cp) {
|
||||
cp++;
|
||||
|
||||
/* add all supported audio files to playlists */
|
||||
for (i=0; i < sizeof(filetypes); i++) {
|
||||
if (filetypes[i].tree_attr == TREE_ATTR_MPA) {
|
||||
cp=strrchr(entry->d_name,'.');
|
||||
if (cp) cp++;
|
||||
if ((!strcasecmp(cp,filetypes[i].extension)) && (cp))
|
||||
if (!strcasecmp(cp, filetypes[i].extension))
|
||||
{
|
||||
char buf[8];
|
||||
write(fd, dirname, strlen(dirname));
|
||||
|
@ -1410,6 +1411,8 @@ static bool add_dir(char* dirname, int len, int fd)
|
|||
}
|
||||
lcd_puts(x,0,buf);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue