mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Add helper function to get index from file extension.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28684 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
2dcc515d15
commit
194bc8660d
1 changed files with 38 additions and 38 deletions
|
@ -196,6 +196,21 @@ static char *filetypes_store_plugin(char *plugin, int n)
|
||||||
viewers[viewer_count++] = n;
|
viewers[viewer_count++] = n;
|
||||||
return filetypes_strdup(plugin);
|
return filetypes_strdup(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int find_extension(const char* extension)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
if (!extension)
|
||||||
|
return -1;
|
||||||
|
for (i=1; i<filetype_count; i++)
|
||||||
|
{
|
||||||
|
if (filetypes[i].extension &&
|
||||||
|
!strcasecmp(extension, filetypes[i].extension))
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static void read_builtin_types(void);
|
static void read_builtin_types(void);
|
||||||
static void read_config(const char* config_file);
|
static void read_config(const char* config_file);
|
||||||
#ifdef HAVE_LCD_COLOR
|
#ifdef HAVE_LCD_COLOR
|
||||||
|
@ -231,15 +246,9 @@ void read_color_theme_file(void) {
|
||||||
hex_to_rgb(color, &custom_colors[MAX_FILETYPES]);
|
hex_to_rgb(color, &custom_colors[MAX_FILETYPES]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (i=1; i<filetype_count; i++)
|
i = find_extension(ext);
|
||||||
{
|
if (i >= 0)
|
||||||
if (filetypes[i].extension &&
|
|
||||||
!strcasecmp(ext, filetypes[i].extension))
|
|
||||||
{
|
|
||||||
hex_to_rgb(color, &custom_colors[i]);
|
hex_to_rgb(color, &custom_colors[i]);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
@ -268,10 +277,8 @@ void read_viewer_theme_file(void)
|
||||||
{
|
{
|
||||||
if (!settings_parseline(buffer, &ext, &icon))
|
if (!settings_parseline(buffer, &ext, &icon))
|
||||||
continue;
|
continue;
|
||||||
for (i=0; i<filetype_count; i++)
|
i = find_extension(ext);
|
||||||
{
|
if (i >= 0)
|
||||||
if (filetypes[i].extension &&
|
|
||||||
!strcasecmp(ext, filetypes[i].extension))
|
|
||||||
{
|
{
|
||||||
if (*icon == '*')
|
if (*icon == '*')
|
||||||
custom_filetype_icons[i] = atoi(icon+1);
|
custom_filetype_icons[i] = atoi(icon+1);
|
||||||
|
@ -284,8 +291,6 @@ void read_viewer_theme_file(void)
|
||||||
global_status.viewer_icon_count++;
|
global_status.viewer_icon_count++;
|
||||||
custom_filetype_icons[i] = Icon_Last_Themeable + number;
|
custom_filetype_icons[i] = Icon_Last_Themeable + number;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -363,7 +368,7 @@ static void read_config(const char* config_file)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rm_whitespaces(line);
|
rm_whitespaces(line);
|
||||||
/* get the extention */
|
/* get the extension */
|
||||||
s = line;
|
s = line;
|
||||||
e = strchr(s, ',');
|
e = strchr(s, ',');
|
||||||
if (!e)
|
if (!e)
|
||||||
|
@ -406,12 +411,10 @@ int filetype_get_attr(const char* file)
|
||||||
if (!extension)
|
if (!extension)
|
||||||
return 0;
|
return 0;
|
||||||
extension++;
|
extension++;
|
||||||
for (i=0; i<filetype_count; i++)
|
|
||||||
{
|
i = find_extension(extension);
|
||||||
if (filetypes[i].extension &&
|
if (i >= 0)
|
||||||
!strcasecmp(extension, filetypes[i].extension))
|
|
||||||
return (filetypes[i].attr<<8)&FILE_ATTR_MASK;
|
return (filetypes[i].attr<<8)&FILE_ATTR_MASK;
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,12 +444,9 @@ int filetype_get_color(const char * name, int attr)
|
||||||
return custom_colors[MAX_FILETYPES];
|
return custom_colors[MAX_FILETYPES];
|
||||||
extension++;
|
extension++;
|
||||||
|
|
||||||
for (i=1; i<filetype_count; i++)
|
i = find_extension(extension);
|
||||||
{
|
if (i >= 0)
|
||||||
if (filetypes[i].extension &&
|
|
||||||
!strcasecmp(extension, filetypes[i].extension))
|
|
||||||
return custom_colors[i];
|
return custom_colors[i];
|
||||||
}
|
|
||||||
return custom_colors[MAX_FILETYPES];
|
return custom_colors[MAX_FILETYPES];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue