1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Daniel Stenberg
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
26 #include "applimits.h"
54 #include "filetypes.h"
59 #include "recorder/recording.h"
67 #include "gwps-common.h"
68 #include "eeprom_settings.h"
69 #include "playlist_catalog.h"
74 #include "buttonbar.h"
76 #include "quickscreen.h"
78 #include "root_menu.h"
80 static const struct filetype
*filetypes
;
81 static int filetypes_count
;
83 struct gui_synclist tree_lists
;
85 /* I put it here because other files doesn't use it yet,
86 * but should be elsewhere since it will be used mostly everywhere */
88 struct gui_buttonbar tree_buttonbar
;
90 static struct tree_context tc
;
92 bool boot_changed
= false;
94 char lastfile
[MAX_PATH
];
95 static char lastdir
[MAX_PATH
];
97 static int lasttable
, lastextra
, lastfirstpos
;
99 static int max_files
= 0;
101 static bool reload_dir
= false;
103 static bool start_wps
= false;
104 static int curr_context
= false;/* id3db or tree*/
106 static int dirbrowse(void);
107 static int ft_play_dirname(char* name
);
108 static void ft_play_filename(char *dir
, char *file
);
109 static void say_filetype(int attr
);
111 static char * tree_get_filename(int selected_item
, void *data
,
112 char *buffer
, size_t buffer_len
)
114 struct tree_context
* local_tc
=(struct tree_context
*)data
;
117 bool stripit
= false;
119 bool id3db
= *(local_tc
->dirfilter
) == SHOW_ID3DB
;
123 return tagtree_get_entry(&tc
, selected_item
)->name
;
128 struct entry
* dc
= local_tc
->dircache
;
129 struct entry
* e
= &dc
[selected_item
];
134 if(!(attr
& ATTR_DIRECTORY
))
136 switch(global_settings
.show_filename_ext
)
139 /* show file extension: off */
143 /* show file extension: on */
146 /* show file extension: only unknown types */
147 stripit
= filetype_supported(attr
);
151 /* show file extension: only when viewing all */
152 stripit
= (*(local_tc
->dirfilter
) != SHOW_ID3DB
) &&
153 (*(local_tc
->dirfilter
) != SHOW_ALL
);
160 return(strip_extension(buffer
, buffer_len
, name
));
165 #ifdef HAVE_LCD_COLOR
166 static int tree_get_filecolor(int selected_item
, void * data
)
168 if (*tc
.dirfilter
== SHOW_ID3DB
)
170 struct tree_context
* local_tc
=(struct tree_context
*)data
;
171 struct entry
* dc
= local_tc
->dircache
;
172 struct entry
* e
= &dc
[selected_item
];
173 return filetype_get_color(e
->name
, e
->attr
);
177 static int tree_get_fileicon(int selected_item
, void * data
)
179 struct tree_context
* local_tc
=(struct tree_context
*)data
;
181 bool id3db
= *(local_tc
->dirfilter
) == SHOW_ID3DB
;
183 return tagtree_get_icon(&tc
);
188 struct entry
* dc
= local_tc
->dircache
;
189 struct entry
* e
= &dc
[selected_item
];
190 return filetype_get_icon(e
->attr
);
194 static int tree_voice_cb(int selected_item
, void * data
)
196 struct tree_context
* local_tc
=(struct tree_context
*)data
;
200 bool id3db
= *(local_tc
->dirfilter
) == SHOW_ID3DB
;
204 attr
= tagtree_get_attr(local_tc
);
205 name
= tagtree_get_entry(local_tc
, selected_item
)->name
;
210 struct entry
* dc
= local_tc
->dircache
;
211 struct entry
* e
= &dc
[selected_item
];
215 bool is_dir
= (attr
& ATTR_DIRECTORY
);
216 bool did_clip
= false;
217 /* First the .talk clip case */
220 if(global_settings
.talk_dir_clip
)
223 if(ft_play_dirname(name
) <0)
224 /* failed, not existing */
227 } else { /* it's a file */
228 if (global_settings
.talk_file_clip
&& (attr
& FILE_ATTR_THUMBNAIL
))
231 ft_play_filename(local_tc
->currdir
, name
);
236 /* say the number or spell if required or as a fallback */
237 switch (is_dir
? global_settings
.talk_dir
: global_settings
.talk_file
)
239 case 1: /* as numbers */
240 talk_id(is_dir
? VOICE_DIR
: VOICE_FILE
, false);
241 talk_number(selected_item
+1 - (is_dir
? 0 : local_tc
->dirsindir
),
243 if(global_settings
.talk_filetype
244 && !is_dir
&& *local_tc
->dirfilter
< NUM_FILTER_MODES
)
247 case 2: /* spelled */
249 if(global_settings
.talk_filetype
)
252 talk_id(VOICE_DIR
, true);
253 else if(*local_tc
->dirfilter
< NUM_FILTER_MODES
)
256 talk_spell(name
, true);
263 bool check_rockboxdir(void)
265 if(!dir_exists(ROCKBOX_DIR
))
266 { /* No need to localise this message.
267 If .rockbox is missing, it wouldn't work anyway */
270 screens
[i
].clear_display();
271 splash(HZ
*2, "No .rockbox directory");
273 screens
[i
].clear_display();
274 splash(HZ
*2, "Installation incomplete");
280 /* do this really late in the init sequence */
281 void tree_gui_init(void)
285 strcpy(tc
.currdir
, "/");
287 #ifdef HAVE_LCD_CHARCELLS
290 screens
[i
].double_height(false);
292 #ifdef HAVE_BUTTONBAR
293 gui_buttonbar_init(&tree_buttonbar
);
294 /* since archos only have one screen, no need to create more than that */
295 gui_buttonbar_set_display(&tree_buttonbar
, &(screens
[SCREEN_MAIN
]) );
297 gui_synclist_init(&tree_lists
, &tree_get_filename
, &tc
, false, 1, NULL
);
298 gui_synclist_set_voice_callback(&tree_lists
, tree_voice_cb
);
299 gui_synclist_set_icon_callback(&tree_lists
, &tree_get_fileicon
);
300 #ifdef HAVE_LCD_COLOR
301 gui_synclist_set_color_callback(&tree_lists
, &tree_get_filecolor
);
307 struct tree_context
* tree_get_context(void)
313 * Returns the position of a given file in the current directory
314 * returns -1 if not found
316 static int tree_get_file_position(char * filename
)
320 /* use lastfile to determine the selected item (default=0) */
321 for (i
=0; i
< tc
.filesindir
; i
++)
323 struct entry
* dc
= tc
.dircache
;
324 struct entry
* e
= &dc
[i
];
325 if (!strcasecmp(e
->name
, filename
))
328 return(-1);/* no file can match, returns undefined */
332 * Called when a new dir is loaded (for example when returning from other apps ...)
333 * also completely redraws the tree
335 static int update_dir(void)
337 bool changed
= false;
339 bool id3db
= *tc
.dirfilter
== SHOW_ID3DB
;
340 /* Checks for changes */
342 if (tc
.currtable
!= lasttable
||
343 tc
.currextra
!= lastextra
||
344 tc
.firstpos
!= lastfirstpos
||
347 if (tagtree_load(&tc
) < 0)
350 lasttable
= tc
.currtable
;
351 lastextra
= tc
.currextra
;
352 lastfirstpos
= tc
.firstpos
;
359 /* if the tc.currdir has been changed, reload it ...*/
360 if (strncmp(tc
.currdir
, lastdir
, sizeof(lastdir
)) || reload_dir
)
362 if (ft_load(&tc
, NULL
) < 0)
364 strcpy(lastdir
, tc
.currdir
);
368 /* if selected item is undefined */
369 if (tc
.selected_item
== -1)
371 /* use lastfile to determine the selected item */
372 tc
.selected_item
= tree_get_file_position(lastfile
);
374 /* If the file doesn't exists, select the first one (default) */
375 if(tc
.selected_item
< 0)
376 tc
.selected_item
= 0;
385 (tc
.dirfull
|| tc
.filesindir
== global_settings
.max_files_in_dir
) )
387 splash(HZ
, ID2P(LANG_SHOWDIR_BUFFER_FULL
));
393 #ifdef HAVE_LCD_BITMAP
394 if (global_settings
.show_path_in_browser
== SHOW_PATH_FULL
395 || global_settings
.show_path_in_browser
== SHOW_PATH_CURRENT
)
397 gui_synclist_set_title(&tree_lists
, tagtree_get_title(&tc
),
398 filetype_get_icon(ATTR_DIRECTORY
));
402 /* Must clear the title as the list is reused */
403 gui_synclist_set_title(&tree_lists
, NULL
, NOICON
);
410 #ifdef HAVE_LCD_BITMAP
411 if (global_settings
.show_path_in_browser
&&
412 *(tc
.dirfilter
) == SHOW_PLUGINS
)
415 if (!strcmp(tc
.currdir
, PLUGIN_GAMES_DIR
))
416 title
= str(LANG_PLUGIN_GAMES
);
417 else if (!strcmp(tc
.currdir
, PLUGIN_APPS_DIR
))
418 title
= str(LANG_PLUGIN_APPS
);
419 else if (!strcmp(tc
.currdir
, PLUGIN_DEMOS_DIR
))
420 title
= str(LANG_PLUGIN_DEMOS
);
421 else title
= str(LANG_PLUGINS
);
422 gui_synclist_set_title(&tree_lists
, title
, Icon_Plugin
);
424 else if (global_settings
.show_path_in_browser
== SHOW_PATH_FULL
)
426 gui_synclist_set_title(&tree_lists
, tc
.currdir
,
427 filetype_get_icon(ATTR_DIRECTORY
));
429 else if (global_settings
.show_path_in_browser
== SHOW_PATH_CURRENT
)
431 char *title
= strrchr(tc
.currdir
, '/') + 1;
434 /* Display "Files" for the root dir */
435 gui_synclist_set_title(&tree_lists
, str(LANG_DIR_BROWSER
),
436 filetype_get_icon(ATTR_DIRECTORY
));
439 gui_synclist_set_title(&tree_lists
, title
,
440 filetype_get_icon(ATTR_DIRECTORY
));
444 /* Must clear the title as the list is reused */
445 gui_synclist_set_title(&tree_lists
, NULL
, NOICON
);
450 gui_synclist_set_nb_items(&tree_lists
, tc
.filesindir
);
451 gui_synclist_set_icon_callback(&tree_lists
, tree_get_fileicon
);
452 if( tc
.selected_item
>= tc
.filesindir
)
453 tc
.selected_item
=tc
.filesindir
-1;
455 gui_synclist_select_item(&tree_lists
, tc
.selected_item
);
456 #ifdef HAVE_BUTTONBAR
457 if (global_settings
.buttonbar
) {
458 if (*tc
.dirfilter
< NUM_FILTER_MODES
)
459 gui_buttonbar_set(&tree_buttonbar
, str(LANG_SYSFONT_DIRBROWSE_F1
),
460 str(LANG_SYSFONT_DIRBROWSE_F2
),
461 str(LANG_SYSFONT_DIRBROWSE_F3
));
463 gui_buttonbar_set(&tree_buttonbar
, "<<<", "", "");
464 gui_buttonbar_draw(&tree_buttonbar
);
467 gui_synclist_draw(&tree_lists
);
468 gui_synclist_speak_item(&tree_lists
);
469 return tc
.filesindir
;
472 /* load tracks from specified directory to resume play */
473 void resume_directory(const char *dir
)
475 int dirfilter
= *tc
.dirfilter
;
478 bool id3db
= *tc
.dirfilter
== SHOW_ID3DB
;
480 /* make sure the dirfilter is sane. The only time it should be possible
481 * thats its not is when resume playlist is called from a plugin
486 *tc
.dirfilter
= global_settings
.dirfilter
;
487 ret
= ft_load(&tc
, dir
);
488 *tc
.dirfilter
= dirfilter
;
493 ft_build_playlist(&tc
, 0);
501 /* Returns the current working directory and also writes cwd to buf if
502 non-NULL. In case of error, returns NULL. */
503 char *getcwd(char *buf
, int size
)
509 strncpy(buf
, tc
.currdir
, size
);
516 /* Force a reload of the directory next time directory browser is called */
517 void reload_directory(void)
522 void get_current_file(char* buffer
, int buffer_len
)
525 /* in ID3DB mode it is a bad idea to call this function */
526 /* (only happens with `follow playlist') */
527 if( *tc
.dirfilter
== SHOW_ID3DB
)
531 struct entry
* dc
= tc
.dircache
;
532 struct entry
* e
= &dc
[tc
.selected_item
];
533 snprintf(buffer
, buffer_len
, "%s/%s", getcwd(NULL
,0),
534 tc
.dirlength
? e
->name
: "");
537 /* Allow apps to change our dirfilter directly (required for sub browsers)
538 if they're suddenly going to become a file browser for example */
539 void set_dirfilter(int l_dirfilter
)
541 *tc
.dirfilter
= l_dirfilter
;
544 /* Selects a file and update tree context properly */
545 void set_current_file(char *path
)
551 /* in ID3DB mode it is a bad idea to call this function */
552 /* (only happens with `follow playlist') */
553 if( *tc
.dirfilter
== SHOW_ID3DB
)
557 /* separate directory from filename */
558 /* gets the directory's name and put it into tc.currdir */
559 name
= strrchr(path
+1,'/');
563 strcpy(tc
.currdir
, path
);
569 strcpy(tc
.currdir
, "/");
573 strcpy(lastfile
, name
);
576 /* If we changed dir we must recalculate the dirlevel
577 and adjust the selected history properly */
578 if (strncmp(tc
.currdir
,lastdir
,sizeof(lastdir
)))
581 tc
.selected_item_history
[tc
.dirlevel
] = -1;
583 /* use '/' to calculate dirlevel */
584 for (i
= 1; path
[i
] != '\0'; i
++)
589 tc
.selected_item_history
[tc
.dirlevel
] = -1;
593 if (ft_load(&tc
, NULL
) >= 0)
595 tc
.selected_item
= tree_get_file_position(lastfile
);
600 /* main loop, handles key events */
601 static int dirbrowse()
605 int button
, oldbutton
;
606 bool reload_root
= false;
607 int lastfilter
= *tc
.dirfilter
;
608 bool lastsortcase
= global_settings
.sort_case
;
609 bool exit_func
= false;
611 char* currdir
= tc
.currdir
; /* just a shortcut */
613 bool id3db
= *tc
.dirfilter
== SHOW_ID3DB
;
616 curr_context
=CONTEXT_ID3DB
;
619 curr_context
=CONTEXT_TREE
;
620 if (tc
.selected_item
< 0)
621 tc
.selected_item
= 0;
630 numentries
= update_dir();
632 if (numentries
== -1)
633 return GO_TO_PREVIOUS
; /* currdir is not a directory */
635 if (*tc
.dirfilter
> NUM_FILTER_MODES
&& numentries
==0)
637 splash(HZ
*2, ID2P(LANG_NO_FILES
));
638 return GO_TO_PREVIOUS
; /* No files found for rockbox_browser() */
641 gui_synclist_draw(&tree_lists
);
643 struct entry
*dircache
= tc
.dircache
;
644 bool restore
= false;
646 tc
.dirlevel
= 0; /* shouldnt be needed.. this code needs work! */
649 static const char *lines
[]={ID2P(LANG_BOOT_CHANGED
), ID2P(LANG_REBOOT_NOW
)};
650 static const struct text_message message
={lines
, 2};
651 if(gui_syncyesno_run(&message
, NULL
, NULL
)==YESNO_YES
)
652 rolo_load("/" BOOTFILE
);
654 boot_changed
= false;
657 button
= get_action(CONTEXT_TREE
,
658 list_do_action_timeout(&tree_lists
, HZ
/2));
660 gui_synclist_do_button(&tree_lists
, &button
,LIST_WRAP_UNLESS_HELD
);
661 tc
.selected_item
= gui_synclist_get_sel_pos(&tree_lists
);
664 /* nothing to do if no files to display */
665 if ( numentries
== 0 )
669 switch (id3db
?tagtree_enter(&tc
):ft_enter(&tc
))
671 switch (ft_enter(&tc
))
674 case 1: reload_dir
= true; break;
675 case 2: start_wps
= true; break;
676 case 3: exit_func
= true; break;
682 case ACTION_STD_CANCEL
:
683 if (*tc
.dirfilter
> NUM_FILTER_MODES
&& tc
.dirlevel
< 1) {
687 if ((*tc
.dirfilter
== SHOW_ID3DB
&& tc
.dirlevel
== 0) ||
688 ((*tc
.dirfilter
!= SHOW_ID3DB
&& !strcmp(currdir
,"/"))))
690 #ifdef HAVE_LCD_BITMAP /* charcell doesnt have ACTION_TREE_PGLEFT so this isnt needed */
691 if (oldbutton
== ACTION_TREE_PGLEFT
)
703 if (ft_exit(&tc
) == 3)
709 case ACTION_TREE_STOP
:
710 if (list_stop_handler())
714 case ACTION_STD_MENU
:
718 #ifdef HAVE_RECORDING
720 return GO_TO_RECSCREEN
;
723 case ACTION_TREE_WPS
:
724 return GO_TO_PREVIOUS_MUSIC
;
726 #ifdef HAVE_QUICKSCREEN
727 case ACTION_STD_QUICKSCREEN
:
728 /* don't enter f2 from plugin browser */
729 if (*tc
.dirfilter
< NUM_FILTER_MODES
)
731 if (quick_screen_quick(button
))
739 /* don't enter f3 from plugin browser */
740 if (*tc
.dirfilter
< NUM_FILTER_MODES
)
742 if (quick_screen_f3(ACTION_F3
))
749 case ACTION_STD_CONTEXT
:
755 onplay_result
= onplay(NULL
, 0, curr_context
);
760 if (tagtree_get_attr(&tc
) == FILE_ATTR_AUDIO
)
762 attr
= FILE_ATTR_AUDIO
;
763 tagtree_get_filename(&tc
, buf
, sizeof(buf
));
766 attr
= ATTR_DIRECTORY
;
771 attr
= dircache
[tc
.selected_item
].attr
;
773 if (currdir
[1]) /* Not in / */
774 snprintf(buf
, sizeof buf
, "%s/%s",
776 dircache
[tc
.selected_item
].name
);
778 snprintf(buf
, sizeof buf
, "/%s",
779 dircache
[tc
.selected_item
].name
);
781 onplay_result
= onplay(buf
, attr
, curr_context
);
783 switch (onplay_result
)
785 case ONPLAY_MAINMENU
:
792 case ONPLAY_RELOAD_DIR
:
796 case ONPLAY_START_PLAY
:
809 /* The 'dir no longer valid' situation will be caught later
810 * by checking the showdir() result. */
815 if (default_event_handler(button
) == SYS_USB_CONNECTED
)
817 if(*tc
.dirfilter
> NUM_FILTER_MODES
)
818 /* leave sub-browsers after usb, doing otherwise
819 might be confusing to the user */
828 if (button
&& !IS_SYSEVENT(button
))
835 /* do we need to rescan dir? */
836 if (reload_dir
|| reload_root
||
837 lastfilter
!= *tc
.dirfilter
||
838 lastsortcase
!= global_settings
.sort_case
)
841 strcpy(currdir
, "/");
854 gui_synclist_select_item(&tree_lists
, 0);
855 gui_synclist_draw(&tree_lists
);
856 tc
.selected_item
= 0;
860 lastfilter
= *tc
.dirfilter
;
861 lastsortcase
= global_settings
.sort_case
;
866 return GO_TO_PREVIOUS
;
868 if (restore
|| reload_dir
) {
869 /* restore display */
870 numentries
= update_dir();
872 if (currdir
[1] && (numentries
< 0))
873 { /* not in root and reload failed */
874 reload_root
= true; /* try root */
882 bool create_playlist(void)
884 char filename
[MAX_PATH
];
886 snprintf(filename
, sizeof filename
, "%s.m3u8",
887 tc
.currdir
[1] ? tc
.currdir
: "/root");
888 splashf(0, "%s %s", str(LANG_CREATING
), filename
);
891 catalog_add_to_a_playlist(tc
.currdir
, ATTR_DIRECTORY
, true, filename
);
897 int rockbox_browse(const char *root
, int dirfilter
)
900 int *last_filter
= tc
.dirfilter
;
901 tc
.dirfilter
= &dirfilter
;
902 tc
.sort_dir
= global_settings
.sort_dir
;
905 if (dirfilter
>= NUM_FILTER_MODES
)
907 static struct tree_context backup
;
911 tc
.selected_item
= 0;
913 memcpy(tc
.currdir
, root
, sizeof(tc
.currdir
));
915 last_context
= curr_context
;
917 ret_val
= dirbrowse();
919 curr_context
= last_context
;
923 static char buf
[MAX_PATH
];
924 if (dirfilter
!= SHOW_ID3DB
)
925 tc
.dirfilter
= &global_settings
.dirfilter
;
927 set_current_file(buf
);
928 ret_val
= dirbrowse();
930 tc
.dirfilter
= last_filter
;
934 void tree_mem_init(void)
936 /* We copy the settings value in case it is changed by the user. We can't
937 use it until the next reboot. */
938 max_files
= global_settings
.max_files_in_dir
;
940 /* initialize tree context struct */
941 memset(&tc
, 0, sizeof(tc
));
942 tc
.dirfilter
= &global_settings
.dirfilter
;
943 tc
.sort_dir
= global_settings
.sort_dir
;
945 tc
.name_buffer_size
= AVERAGE_FILENAME_LENGTH
* max_files
;
946 tc
.name_buffer
= buffer_alloc(tc
.name_buffer_size
);
948 tc
.dircache_size
= max_files
* sizeof(struct entry
);
949 tc
.dircache
= buffer_alloc(tc
.dircache_size
);
950 tree_get_filetypes(&filetypes
, &filetypes_count
);
953 bool bookmark_play(char *resume_file
, int index
, int offset
, int seed
,
957 char* suffix
= strrchr(resume_file
, '.');
958 bool started
= false;
960 if (suffix
!= NULL
&&
961 (!strcasecmp(suffix
, ".m3u") || !strcasecmp(suffix
, ".m3u8")))
963 /* Playlist playback */
965 /* check that the file exists */
966 if(!file_exists(resume_file
))
969 slash
= strrchr(resume_file
,'/');
979 if (playlist_create(cp
, slash
+1) != -1)
981 if (global_settings
.playlist_shuffle
)
982 playlist_shuffle(seed
, -1);
983 playlist_start(index
,offset
);
991 /* Directory playback */
993 if (playlist_create(resume_file
, NULL
) != -1)
996 resume_directory(resume_file
);
997 if (global_settings
.playlist_shuffle
)
998 playlist_shuffle(seed
, -1);
1000 /* Check if the file is at the same spot in the directory,
1001 else search for it */
1002 peek_filename
= playlist_peek(index
);
1004 if (peek_filename
== NULL
)
1007 if (strcmp(strrchr(peek_filename
, '/') + 1, filename
))
1009 for ( i
=0; i
< playlist_amount(); i
++ )
1011 peek_filename
= playlist_peek(i
);
1013 if (peek_filename
== NULL
)
1016 if (!strcmp(strrchr(peek_filename
, '/') + 1, filename
))
1019 if (i
< playlist_amount())
1024 playlist_start(index
,offset
);
1034 static void say_filetype(int attr
)
1036 /* try to find a voice ID for the extension, if known */
1038 attr
&= FILE_ATTR_MASK
; /* file type */
1039 for (j
=0; j
<filetypes_count
; j
++)
1040 if (attr
== filetypes
[j
].tree_attr
)
1042 talk_id(filetypes
[j
].voiceclip
, true);
1047 static int ft_play_dirname(char* name
)
1049 #if CONFIG_CODEC != SWCODEC
1050 if (audio_status() & AUDIO_STATUS_PLAY
)
1054 if(talk_file(tc
.currdir
, name
, dir_thumbnail_name
, NULL
,
1057 if(global_settings
.talk_filetype
)
1058 talk_id(VOICE_DIR
, true);
1065 static void ft_play_filename(char *dir
, char *file
)
1067 #if CONFIG_CODEC != SWCODEC
1068 if (audio_status() & AUDIO_STATUS_PLAY
)
1072 if (strlen(file
) >= strlen(file_thumbnail_ext
)
1073 && strcasecmp(&file
[strlen(file
) - strlen(file_thumbnail_ext
)],
1074 file_thumbnail_ext
))
1075 /* file has no .talk extension */
1076 talk_file(dir
, NULL
, file
, file_thumbnail_ext
,
1079 /* it already is a .talk file, play this directly, but prefix it. */
1080 talk_file(dir
, NULL
, file
, NULL
,
1081 TALK_IDARRAY(LANG_VOICE_DIR_HOVER
), false);
1084 /* These two functions are called by the USB and shutdown handlers */
1085 void tree_flush(void)
1087 #ifdef HAVE_TAGCACHE
1088 tagcache_shutdown();
1091 #ifdef HAVE_TC_RAMCACHE
1092 tagcache_unload_ramcache();
1095 #ifdef HAVE_DIRCACHE
1097 int old_val
= global_status
.dircache_size
;
1098 if (global_settings
.dircache
)
1100 if (!dircache_is_initializing())
1101 global_status
.dircache_size
= dircache_get_cache_size();
1102 # ifdef HAVE_EEPROM_SETTINGS
1103 if (firmware_settings
.initialized
)
1110 global_status
.dircache_size
= 0;
1112 if (old_val
!= global_status
.dircache_size
)
1118 void tree_restore(void)
1120 #ifdef HAVE_EEPROM_SETTINGS
1121 firmware_settings
.disk_clean
= false;
1124 #ifdef HAVE_TC_RAMCACHE
1125 remove(TAGCACHE_STATEFILE
);
1128 #ifdef HAVE_DIRCACHE
1129 remove(DIRCACHE_FILE
);
1130 if (global_settings
.dircache
)
1132 /* Print "Scanning disk..." to the display. */
1133 splash(0, str(LANG_SCANNING_DISK
));
1135 dircache_build(global_status
.dircache_size
);
1138 #ifdef HAVE_TAGCACHE
1139 tagcache_start_scan();