summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/onplay.c12
-rw-r--r--apps/playlist.c2
-rw-r--r--apps/tree.c168
-rw-r--r--apps/tree.h24
4 files changed, 97 insertions, 109 deletions
diff --git a/apps/onplay.c b/apps/onplay.c
index 67793dffea..7598aa3125 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -59,7 +59,7 @@ static bool add_to_playlist(int position, bool queue)
59 if (new_playlist) 59 if (new_playlist)
60 playlist_create(NULL, NULL); 60 playlist_create(NULL, NULL);
61 61
62 if (selected_file_attr & TREE_ATTR_MPA) 62 if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA)
63 playlist_insert_track(selected_file, position, queue); 63 playlist_insert_track(selected_file, position, queue);
64 else if (selected_file_attr & ATTR_DIRECTORY) 64 else if (selected_file_attr & ATTR_DIRECTORY)
65 { 65 {
@@ -101,7 +101,7 @@ static bool add_to_playlist(int position, bool queue)
101 101
102 playlist_insert_directory(selected_file, position, queue, recurse); 102 playlist_insert_directory(selected_file, position, queue, recurse);
103 } 103 }
104 else if (selected_file_attr & TREE_ATTR_M3U) 104 else if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)
105 playlist_insert_playlist(selected_file, position, queue); 105 playlist_insert_playlist(selected_file, position, queue);
106 106
107 if (new_playlist && (playlist_amount() > 0)) 107 if (new_playlist && (playlist_amount() > 0))
@@ -158,7 +158,7 @@ static bool playlist_options(void)
158 args[i].queue = true; 158 args[i].queue = true;
159 i++; 159 i++;
160 } 160 }
161 else if ((selected_file_attr & TREE_ATTR_MPA) || 161 else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) ||
162 (selected_file_attr & ATTR_DIRECTORY)) 162 (selected_file_attr & ATTR_DIRECTORY))
163 { 163 {
164 menu[i].desc = str(LANG_INSERT); 164 menu[i].desc = str(LANG_INSERT);
@@ -489,8 +489,8 @@ int onplay(char* file, int attr)
489 selected_file = file; 489 selected_file = file;
490 selected_file_attr = attr; 490 selected_file_attr = attr;
491 491
492 if ((attr & TREE_ATTR_MPA) || (attr & ATTR_DIRECTORY) || 492 if (((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || (attr & ATTR_DIRECTORY) ||
493 ((attr & TREE_ATTR_M3U) && (mpeg_status() & MPEG_STATUS_PLAY))) 493 (((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U) && (mpeg_status() & MPEG_STATUS_PLAY)))
494 { 494 {
495 menu[i].desc = str(LANG_PLAYINDICES_PLAYLIST); 495 menu[i].desc = str(LANG_PLAYINDICES_PLAYLIST);
496 menu[i].function = playlist_options; 496 menu[i].function = playlist_options;
@@ -508,7 +508,7 @@ int onplay(char* file, int attr)
508 i++; 508 i++;
509 } 509 }
510 510
511 if (attr & TREE_ATTR_MPA) 511 if ((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA)
512 { 512 {
513 menu[i].desc = str(LANG_VBRFIX); 513 menu[i].desc = str(LANG_VBRFIX);
514 menu[i].function = vbr_fix; 514 menu[i].function = vbr_fix;
diff --git a/apps/playlist.c b/apps/playlist.c
index 0843e937c4..ff6ef0ed37 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -468,7 +468,7 @@ static int add_directory_to_playlist(char *dirname, int *position, bool queue,
468 else 468 else
469 continue; 469 continue;
470 } 470 }
471 else if (files[i].attr & TREE_ATTR_MPA) 471 else if ((files[i].attr & TREE_ATTR_MASK) == TREE_ATTR_MPA)
472 { 472 {
473 int insert_pos; 473 int insert_pos;
474 474
diff --git a/apps/tree.c b/apps/tree.c
index a71db78968..25f4434ef5 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -61,6 +61,38 @@
61#define BOOTFILE "archos.mod" 61#define BOOTFILE "archos.mod"
62#endif 62#endif
63 63
64/* a table for the know file types */
65static struct
66{
67 char* extension; /* extension for which the file type is recognized */
68 int tree_attr; /* which identifier */
69 int icon; /* the icon which shall be used for it, -1 if unknown */
70 /* To have it extendable, there could be more useful stuff in here,
71 like handler functions, plugin name, etc. */
72} filetypes[] = {
73 { ".mp3", TREE_ATTR_MPA, File },
74 { ".mp2", TREE_ATTR_MPA, File },
75 { ".mpa", TREE_ATTR_MPA, File },
76 { ".m3u", TREE_ATTR_M3U, Playlist },
77 { ".cfg", TREE_ATTR_CFG, Config },
78 { ".wps", TREE_ATTR_WPS, Wps, },
79 { ".txt", TREE_ATTR_TXT, Text },
80 { ".lng", TREE_ATTR_LNG, Language },
81 { ".rock",TREE_ATTR_ROCK,Plugin },
82#ifdef HAVE_LCD_BITMAP
83 { ".fnt", TREE_ATTR_FONT,Font },
84 { ".ch8", TREE_ATTR_CH8, -1 },
85#endif
86#ifndef SIMULATOR
87#ifdef ARCHOS_RECORDER
88 { ".ucl", TREE_ATTR_UCL, Flashfile},
89 { ".ajz", TREE_ATTR_MOD, Mod_Ajz },
90#else
91 { ".mod", TREE_ATTR_MOD, Mod_Ajz },
92#endif
93#endif /* #ifndef SIMULATOR */
94};
95
64/* Boot value of global_settings.max_files_in_dir */ 96/* Boot value of global_settings.max_files_in_dir */
65static int max_files_in_dir; 97static int max_files_in_dir;
66 98
@@ -284,38 +316,20 @@ struct entry* load_and_sort_directory(char *dirname, int *dirfilter,
284 316
285 dptr->attr = entry->attribute; 317 dptr->attr = entry->attribute;
286 318
287 /* mark mp? and m3u files as such */ 319 /* check for known file types */
288 if ( !(dptr->attr & ATTR_DIRECTORY) && (len > 4) ) { 320 if ( !(dptr->attr & ATTR_DIRECTORY) && (len > 4) )
289 if (!strcasecmp(&entry->d_name[len-4], ".mp3") || 321 {
290 (!strcasecmp(&entry->d_name[len-4], ".mp2")) || 322 unsigned j;
291 (!strcasecmp(&entry->d_name[len-4], ".mpa"))) 323 for (j=0; j<sizeof(filetypes)/sizeof(*filetypes); j++)
292 dptr->attr |= TREE_ATTR_MPA; 324 {
293 else if (!strcasecmp(&entry->d_name[len-4], ".m3u")) 325 if (!strcasecmp(
294 dptr->attr |= TREE_ATTR_M3U; 326 &entry->d_name[len-strlen(filetypes[j].extension)],
295 else if (!strcasecmp(&entry->d_name[len-4], ".cfg")) 327 filetypes[j].extension))
296 dptr->attr |= TREE_ATTR_CFG; 328 {
297 else if (!strcasecmp(&entry->d_name[len-4], ".wps")) 329 dptr->attr |= filetypes[j].tree_attr;
298 dptr->attr |= TREE_ATTR_WPS; 330 break;
299 else if (!strcasecmp(&entry->d_name[len-4], ".txt")) 331 }
300 dptr->attr |= TREE_ATTR_TXT; 332 }
301 else if (!strcasecmp(&entry->d_name[len-4], ".lng"))
302 dptr->attr |= TREE_ATTR_LNG;
303#ifdef HAVE_RECORDER_KEYPAD
304 else if (!strcasecmp(&entry->d_name[len-4], ".fnt"))
305 dptr->attr |= TREE_ATTR_FONT;
306 else if (!strcasecmp(&entry->d_name[len-4], ".ajz"))
307#else
308 else if (!strcasecmp(&entry->d_name[len-4], ".mod"))
309#endif
310 dptr->attr |= TREE_ATTR_MOD;
311 else if (!strcasecmp(&entry->d_name[len-5], ".rock"))
312 dptr->attr |= TREE_ATTR_ROCK;
313 else if (!strcasecmp(&entry->d_name[len-4], ".ucl"))
314 dptr->attr |= TREE_ATTR_UCL;
315#ifdef HAVE_LCD_BITMAP
316 else if (!strcasecmp(&entry->d_name[len-4], ".ch8"))
317 dptr->attr |= TREE_ATTR_CH8;
318#endif
319 } 333 }
320 334
321 /* memorize/compare details about the boot file */ 335 /* memorize/compare details about the boot file */
@@ -330,17 +344,19 @@ struct entry* load_and_sort_directory(char *dirname, int *dirfilter,
330 } 344 }
331 345
332 /* filter out non-visible files */ 346 /* filter out non-visible files */
333 if ((*dirfilter == SHOW_PLAYLIST && 347 if (!(dptr->attr & ATTR_DIRECTORY) && (
334 !(dptr->attr & (ATTR_DIRECTORY|TREE_ATTR_M3U))) || 348 (*dirfilter == SHOW_PLAYLIST &&
335 (*dirfilter == SHOW_MUSIC && 349 (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_M3U) ||
336 !(dptr->attr & (ATTR_DIRECTORY|TREE_ATTR_MPA|TREE_ATTR_M3U))) || 350 ((*dirfilter == SHOW_MUSIC &&
351 (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_MPA) &&
352 (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_M3U) ||
337 (*dirfilter == SHOW_SUPPORTED && !(dptr->attr & TREE_ATTR_MASK)) || 353 (*dirfilter == SHOW_SUPPORTED && !(dptr->attr & TREE_ATTR_MASK)) ||
338 (*dirfilter == SHOW_WPS && !(dptr->attr & TREE_ATTR_WPS)) || 354 (*dirfilter == SHOW_WPS && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_WPS) ||
339 (*dirfilter == SHOW_CFG && !(dptr->attr & TREE_ATTR_CFG)) || 355 (*dirfilter == SHOW_CFG && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_CFG) ||
340 (*dirfilter == SHOW_LNG && !(dptr->attr & TREE_ATTR_LNG)) || 356 (*dirfilter == SHOW_LNG && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_LNG) ||
341 (*dirfilter == SHOW_MOD && !(dptr->attr & TREE_ATTR_MOD)) || 357 (*dirfilter == SHOW_MOD && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_MOD) ||
342 (*dirfilter == SHOW_FONT && !(dptr->attr & TREE_ATTR_FONT)) || 358 (*dirfilter == SHOW_FONT && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_FONT) ||
343 (*dirfilter == SHOW_PLUGINS && !(dptr->attr & TREE_ATTR_ROCK))) 359 (*dirfilter == SHOW_PLUGINS && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_ROCK)))
344 { 360 {
345 i--; 361 i--;
346 continue; 362 continue;
@@ -459,66 +475,38 @@ static int showdir(char *path, int start, int *dirfilter)
459 475
460 for ( i=start; i < start+tree_max_on_screen; i++ ) { 476 for ( i=start; i < start+tree_max_on_screen; i++ ) {
461 int len; 477 int len;
478 unsigned j;
462 479
463 if ( i >= filesindir ) 480 if ( i >= filesindir )
464 break; 481 break;
465 482
466 len = strlen(dircache[i].name); 483 len = strlen(dircache[i].name);
467 484
468 switch ( dircache[i].attr & TREE_ATTR_MASK ) { 485 if (dircache[i].attr & ATTR_DIRECTORY)
469 case ATTR_DIRECTORY: 486 {
470 icon_type = Folder; 487 icon_type = Folder;
471 break; 488 }
472 489 else
473 case TREE_ATTR_M3U: 490 {
474 icon_type = Playlist; 491 /* search which icon to use */
475 break; 492 icon_type = -1; /* default to none */
476 493 for (j=0; j<sizeof(filetypes)/sizeof(*filetypes); j++)
477 case TREE_ATTR_MPA: 494 {
478 icon_type = File; 495 if ((dircache[i].attr & TREE_ATTR_MASK) == filetypes[j].tree_attr)
479 break; 496 {
480 497 icon_type = filetypes[j].icon;
481 case TREE_ATTR_WPS: 498 break;
482 icon_type = Wps; 499 }
483 break; 500 }
484
485 case TREE_ATTR_CFG:
486 icon_type = Config;
487 break;
488
489 case TREE_ATTR_TXT:
490 icon_type = Text;
491 break;
492
493 case TREE_ATTR_LNG:
494 icon_type = Language;
495 break;
496
497 case TREE_ATTR_MOD:
498 icon_type = Mod_Ajz;
499 break;
500
501#ifdef HAVE_LCD_BITMAP
502 case TREE_ATTR_UCL:
503 icon_type = Flashfile;
504 break;
505#endif
506
507 case TREE_ATTR_ROCK:
508 icon_type = Plugin;
509 break;
510 501
511#ifdef HAVE_LCD_BITMAP 502 if (icon_type == -1)
512 case TREE_ATTR_FONT: 503 {
513 icon_type = Font;
514 break;
515#endif
516 default:
517#ifdef HAVE_LCD_BITMAP 504#ifdef HAVE_LCD_BITMAP
518 icon_type = 0; 505 icon_type = 0;
519#else 506#else
520 icon_type = Unknown; 507 icon_type = Unknown;
521#endif 508#endif
509 }
522 } 510 }
523 511
524 if (icon_type && global_settings.show_icons) { 512 if (icon_type && global_settings.show_icons) {
diff --git a/apps/tree.h b/apps/tree.h
index 3086c8914b..fdc9641917 100644
--- a/apps/tree.h
+++ b/apps/tree.h
@@ -27,18 +27,18 @@ struct entry {
27}; 27};
28 28
29/* using attribute not used by FAT */ 29/* using attribute not used by FAT */
30#define TREE_ATTR_MPA 0x40 /* mpeg audio file */ 30#define TREE_ATTR_MPA 0x0100 /* mpeg audio file */
31#define TREE_ATTR_M3U 0x80 /* playlist */ 31#define TREE_ATTR_M3U 0x0200 /* playlist */
32#define TREE_ATTR_WPS 0x100 /* wps config file */ 32#define TREE_ATTR_WPS 0x0300 /* wps config file */
33#define TREE_ATTR_MOD 0x200 /* firmware file */ 33#define TREE_ATTR_MOD 0x0400 /* firmware file */
34#define TREE_ATTR_CFG 0x400 /* config file */ 34#define TREE_ATTR_CFG 0x0500 /* config file */
35#define TREE_ATTR_TXT 0x500 /* text file */ 35#define TREE_ATTR_TXT 0x0600 /* text file */
36#define TREE_ATTR_FONT 0x800 /* font file */ 36#define TREE_ATTR_FONT 0x0700 /* font file */
37#define TREE_ATTR_LNG 0x1000 /* binary lang file */ 37#define TREE_ATTR_LNG 0x0800 /* binary lang file */
38#define TREE_ATTR_ROCK 0x2000 /* binary rockbox plugin */ 38#define TREE_ATTR_ROCK 0x0900 /* binary rockbox plugin */
39#define TREE_ATTR_UCL 0x4000 /* rockbox flash image */ 39#define TREE_ATTR_UCL 0x0A00 /* rockbox flash image */
40#define TREE_ATTR_CH8 0x8000 /* chip-8 game */ 40#define TREE_ATTR_CH8 0x0B00 /* chip-8 game */
41#define TREE_ATTR_MASK 0xffd0 /* which bits tree.c uses (above + DIR) */ 41#define TREE_ATTR_MASK 0xFFC0 /* which bits tree.c uses (above) */
42 42
43void tree_init(void); 43void tree_init(void);
44void browse_root(void); 44void browse_root(void);