summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/filetypes.c12
-rw-r--r--apps/filetypes.h2
-rw-r--r--apps/tree.c61
3 files changed, 40 insertions, 35 deletions
diff --git a/apps/filetypes.c b/apps/filetypes.c
index 30ab2c34e5..721d5326ea 100644
--- a/apps/filetypes.c
+++ b/apps/filetypes.c
@@ -209,18 +209,20 @@ bool filetype_supported(int attr)
209} 209}
210 210
211/* get the "dynamic" attribute for an extension */ 211/* get the "dynamic" attribute for an extension */
212int filetype_get_attr(char* name) 212int filetype_get_attr(const char* name)
213{ 213{
214 int i; 214 int i;
215 char *cp; 215 const char *cp = strrchr(name,'.');
216
217 if (!cp) /* no extension? -> can't be a supported type */
218 return 0;
219 cp++;
216 220
217 for (i=0; i < cnt_exttypes; i++) 221 for (i=0; i < cnt_exttypes; i++)
218 { 222 {
219 if (exttypes[i].extension) 223 if (exttypes[i].extension)
220 { 224 {
221 cp=strrchr(name,'.'); 225 if (!strcasecmp(cp,exttypes[i].extension))
222 if (cp) cp++;
223 if ((!strcasecmp(cp,exttypes[i].extension)) && (cp))
224 { 226 {
225 return ((((unsigned long)exttypes[i].type - 227 return ((((unsigned long)exttypes[i].type -
226 (unsigned long)&filetypes[0]) / 228 (unsigned long)&filetypes[0]) /
diff --git a/apps/filetypes.h b/apps/filetypes.h
index 200d338039..e72dd6ffd3 100644
--- a/apps/filetypes.h
+++ b/apps/filetypes.h
@@ -23,7 +23,7 @@
23#include <tree.h> 23#include <tree.h>
24#include <menu.h> 24#include <menu.h>
25 25
26int filetype_get_attr(char*); 26int filetype_get_attr(const char*);
27#ifdef HAVE_LCD_BITMAP 27#ifdef HAVE_LCD_BITMAP
28const char* filetype_get_icon(int); 28const char* filetype_get_icon(int);
29#else 29#else
diff --git a/apps/tree.c b/apps/tree.c
index eec71aeb93..a88d58b165 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -1376,40 +1376,43 @@ static bool add_dir(char* dirname, int len, int fd)
1376 else { 1376 else {
1377 int x = strlen(entry->d_name); 1377 int x = strlen(entry->d_name);
1378 unsigned int i; 1378 unsigned int i;
1379 char *cp; 1379 char *cp = strrchr(entry->d_name,'.');
1380 1380
1381 /* add all supported audio files to playlists */ 1381 if (cp) {
1382 for (i=0; i < sizeof(filetypes); i++) { 1382 cp++;
1383 if (filetypes[i].tree_attr == TREE_ATTR_MPA) { 1383
1384 cp=strrchr(entry->d_name,'.'); 1384 /* add all supported audio files to playlists */
1385 if (cp) cp++; 1385 for (i=0; i < sizeof(filetypes); i++) {
1386 if ((!strcasecmp(cp,filetypes[i].extension)) && (cp)) 1386 if (filetypes[i].tree_attr == TREE_ATTR_MPA) {
1387 { 1387 if (!strcasecmp(cp, filetypes[i].extension))
1388 char buf[8]; 1388 {
1389 write(fd, dirname, strlen(dirname)); 1389 char buf[8];
1390 write(fd, "/", 1); 1390 write(fd, dirname, strlen(dirname));
1391 write(fd, entry->d_name, x); 1391 write(fd, "/", 1);
1392 write(fd, "\n", 1); 1392 write(fd, entry->d_name, x);
1393 1393 write(fd, "\n", 1);
1394 plsize++; 1394
1395 snprintf(buf, sizeof buf, "%d", plsize); 1395 plsize++;
1396 snprintf(buf, sizeof buf, "%d", plsize);
1396#ifdef HAVE_LCD_BITMAP 1397#ifdef HAVE_LCD_BITMAP
1397 lcd_puts(0,4,buf); 1398 lcd_puts(0,4,buf);
1398 lcd_update(); 1399 lcd_update();
1399#else 1400#else
1400 x = 10; 1401 x = 10;
1401 if (plsize > 999) 1402 if (plsize > 999)
1402 x=7; 1403 x=7;
1403 else {
1404 if (plsize > 99)
1405 x=8;
1406 else { 1404 else {
1407 if (plsize > 9) 1405 if (plsize > 99)
1408 x=9; 1406 x=8;
1407 else {
1408 if (plsize > 9)
1409 x=9;
1410 }
1409 } 1411 }
1410 } 1412 lcd_puts(x,0,buf);
1411 lcd_puts(x,0,buf);
1412#endif 1413#endif
1414 break;
1415 }
1413 } 1416 }
1414 } 1417 }
1415 } 1418 }