GSoC/Buflib: Add buflib memory alocator to the core.
[kugel-rb.git] / apps / filetree.c
blob1aee80b6b28438216427b7bf1127d9fee03d3cd7
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 by Björn 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 ****************************************************************************/
21 #include <stdlib.h>
22 #include <file.h>
23 #include <dir.h>
24 #include <string.h>
25 #include <kernel.h>
26 #include <lcd.h>
27 #include <debug.h>
28 #include <font.h>
29 #include <limits.h>
30 #include "bookmark.h"
31 #include "tree.h"
32 #include "settings.h"
33 #include "filetypes.h"
34 #include "talk.h"
35 #include "playlist.h"
36 #include "lang.h"
37 #include "language.h"
38 #include "screens.h"
39 #include "plugin.h"
40 #include "rolo.h"
41 #include "splash.h"
42 #include "cuesheet.h"
43 #include "filetree.h"
44 #include "misc.h"
45 #include "strnatcmp.h"
46 #include "playlist_viewer.h"
47 #ifdef HAVE_LCD_BITMAP
48 #include "keyboard.h"
49 #endif
51 #if CONFIG_TUNER
52 #include "radio.h"
53 #endif
54 #include "wps.h"
56 static int compare_sort_dir; /* qsort key for sorting directories */
58 int ft_build_playlist(struct tree_context* c, int start_index)
60 int i;
61 int start=start_index;
63 struct entry *entries = c->cache.entries;
65 for(i = 0;i < c->filesindir;i++)
67 if((entries[i].attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO)
69 if (playlist_add(entries[i].name) < 0)
70 break;
72 else
74 /* Adjust the start index when se skip non-MP3 entries */
75 if(i < start)
76 start_index--;
80 return start_index;
83 /* Start playback of a playlist, checking for bookmark autoload, modified
84 * playlists, etc., as required. Returns false if playback wasn't started,
85 * or started via bookmark autoload, true otherwise.
87 * Pointers to both the full pathname and the separated parts needed to
88 * avoid allocating yet another path buffer on the stack (and save some
89 * code; the caller typically needs to create the full pathname anyway)...
91 bool ft_play_playlist(char* pathname, char* dirname, char* filename)
93 if (global_settings.party_mode && audio_status())
95 splash(HZ, ID2P(LANG_PARTY_MODE));
96 return false;
99 if (bookmark_autoload(pathname))
101 return false;
104 splash(0, ID2P(LANG_WAIT));
106 /* about to create a new current playlist...
107 allow user to cancel the operation */
108 if (!warn_on_pl_erase())
109 return false;
111 if (playlist_create(dirname, filename) != -1)
113 if (global_settings.playlist_shuffle)
115 playlist_shuffle(current_tick, -1);
118 playlist_start(0, 0);
119 return true;
122 return false;
125 /* walk a directory and check all entries if a .talk file exists */
126 static void check_file_thumbnails(struct tree_context* c)
128 int i;
129 struct dirent *entry;
130 struct entry* entries = c->cache.entries;
131 DIR *dir;
133 dir = opendir(c->currdir);
134 if(!dir)
135 return;
136 /* mark all files as non talking, except the .talk ones */
137 for (i=0; i < c->filesindir; i++)
139 if (entries[i].attr & ATTR_DIRECTORY)
140 continue; /* we're not touching directories */
142 if (strcasecmp(file_thumbnail_ext,
143 &entries[i].name[strlen(entries[i].name)
144 - strlen(file_thumbnail_ext)]))
145 { /* no .talk file */
146 entries[i].attr &= ~FILE_ATTR_THUMBNAIL; /* clear */
148 else
149 { /* .talk file, we later let them speak themselves */
150 entries[i].attr |= FILE_ATTR_THUMBNAIL; /* set */
154 while((entry = readdir(dir)) != 0) /* walk directory */
156 int ext_pos;
157 struct dirinfo info = dir_get_info(dir, entry);
158 ext_pos = strlen((char *)entry->d_name) - strlen(file_thumbnail_ext);
159 if (ext_pos <= 0 /* too short to carry ".talk" */
160 || (info.attribute & ATTR_DIRECTORY) /* no file */
161 || strcasecmp((char *)&entry->d_name[ext_pos], file_thumbnail_ext))
162 { /* or doesn't end with ".talk", no candidate */
163 continue;
166 /* terminate the (disposable) name in dir buffer,
167 this truncates off the ".talk" without needing an extra buffer */
168 entry->d_name[ext_pos] = '\0';
170 /* search corresponding file in dir cache */
171 for (i=0; i < c->filesindir; i++)
173 if (!strcasecmp(entries[i].name, (char *)entry->d_name))
174 { /* match */
175 entries[i].attr |= FILE_ATTR_THUMBNAIL; /* set the flag */
176 break; /* exit search loop, because we found it */
180 closedir(dir);
183 /* support function for qsort() */
184 static int compare(const void* p1, const void* p2)
186 struct entry* e1 = (struct entry*)p1;
187 struct entry* e2 = (struct entry*)p2;
188 int criteria;
190 if (e1->attr & ATTR_DIRECTORY && e2->attr & ATTR_DIRECTORY)
191 { /* two directories */
192 criteria = compare_sort_dir;
194 #ifdef HAVE_MULTIVOLUME
195 if (e1->attr & ATTR_VOLUME || e2->attr & ATTR_VOLUME)
196 { /* a volume identifier is involved */
197 if (e1->attr & ATTR_VOLUME && e2->attr & ATTR_VOLUME)
198 criteria = SORT_ALPHA; /* two volumes: sort alphabetically */
199 else /* only one is a volume: volume first */
200 return (e2->attr & ATTR_VOLUME) - (e1->attr & ATTR_VOLUME);
202 #endif
205 else if (!(e1->attr & ATTR_DIRECTORY) && !(e2->attr & ATTR_DIRECTORY))
206 { /* two files */
207 criteria = global_settings.sort_file;
209 else /* dir and file, dir goes first */
210 return (e2->attr & ATTR_DIRECTORY) - (e1->attr & ATTR_DIRECTORY);
212 switch(criteria)
214 case SORT_TYPE:
215 case SORT_TYPE_REVERSED:
217 int t1 = e1->attr & FILE_ATTR_MASK;
218 int t2 = e2->attr & FILE_ATTR_MASK;
220 if (!t1) /* unknown type */
221 t1 = INT_MAX; /* gets a high number, to sort after known */
222 if (!t2) /* unknown type */
223 t2 = INT_MAX; /* gets a high number, to sort after known */
225 if (t1 != t2) /* if different */
226 return (t1 - t2) * (criteria == SORT_TYPE_REVERSED ? -1 : 1);
227 /* else fall through to alphabetical sorting */
230 case SORT_DATE:
231 case SORT_DATE_REVERSED:
232 /* Ignore SORT_TYPE */
233 if (criteria == SORT_DATE || criteria == SORT_DATE_REVERSED)
235 if (e1->time_write != e2->time_write)
236 return (e1->time_write - e2->time_write)
237 * (criteria == SORT_DATE_REVERSED ? -1 : 1);
238 /* else fall through to alphabetical sorting */
241 case SORT_ALPHA:
242 case SORT_ALPHA_REVERSED:
244 if (global_settings.sort_case)
246 if (global_settings.interpret_numbers == SORT_INTERPRET_AS_NUMBER)
247 return strnatcmp(e1->name, e2->name)
248 * (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
249 else
250 return strncmp(e1->name, e2->name, MAX_PATH)
251 * (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
253 else
255 if (global_settings.interpret_numbers == SORT_INTERPRET_AS_NUMBER)
256 return strnatcasecmp(e1->name, e2->name)
257 * (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
258 else
259 return strncasecmp(e1->name, e2->name, MAX_PATH)
260 * (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
265 return 0; /* never reached */
268 /* load and sort directory into the tree's cache. returns NULL on failure. */
269 int ft_load(struct tree_context* c, const char* tempdir)
271 int files_in_dir = 0;
272 int name_buffer_used = 0;
273 struct dirent *entry;
274 bool (*callback_show_item)(char *, int, struct tree_context *) = NULL;
275 DIR *dir;
277 if (tempdir)
278 dir = opendir(tempdir);
279 else
281 dir = opendir(c->currdir);
282 callback_show_item = c->browse? c->browse->callback_show_item: NULL;
284 if(!dir)
285 return -1; /* not a directory */
287 c->dirsindir = 0;
288 c->dirfull = false;
290 while ((entry = readdir(dir))) {
291 int len;
292 struct dirinfo info;
293 struct entry* table = c->cache.entries;
294 struct entry* dptr = &table[files_in_dir];
295 if (!entry)
296 break;
298 info = dir_get_info(dir, entry);
299 len = strlen((char *)entry->d_name);
301 /* skip directories . and .. */
302 if ((info.attribute & ATTR_DIRECTORY) &&
303 (((len == 1) && (!strncmp((char *)entry->d_name, ".", 1))) ||
304 ((len == 2) && (!strncmp((char *)entry->d_name, "..", 2))))) {
305 continue;
308 /* Skip FAT volume ID */
309 if (info.attribute & ATTR_VOLUME_ID) {
310 continue;
313 /* filter out dotfiles and hidden files */
314 if (*c->dirfilter != SHOW_ALL &&
315 ((entry->d_name[0]=='.') ||
316 (info.attribute & ATTR_HIDDEN))) {
317 continue;
320 dptr->attr = info.attribute;
322 /* check for known file types */
323 if ( !(dptr->attr & ATTR_DIRECTORY) )
324 dptr->attr |= filetype_get_attr((char *)entry->d_name);
326 /* filter out non-visible files */
327 if ((!(dptr->attr & ATTR_DIRECTORY) && (
328 (*c->dirfilter == SHOW_PLAYLIST &&
329 (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) ||
330 ((*c->dirfilter == SHOW_MUSIC &&
331 (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) &&
332 (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) ||
333 (*c->dirfilter == SHOW_SUPPORTED && !filetype_supported(dptr->attr)))) ||
334 (*c->dirfilter == SHOW_WPS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_WPS) ||
335 #ifdef HAVE_LCD_BITMAP
336 (*c->dirfilter == SHOW_FONT && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FONT) ||
337 (*c->dirfilter == SHOW_SBS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_SBS) ||
338 #if CONFIG_TUNER
339 (*c->dirfilter == SHOW_FMS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FMS) ||
340 #endif
341 #endif
342 #ifdef HAVE_REMOTE_LCD
343 (*c->dirfilter == SHOW_RWPS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RWPS) ||
344 (*c->dirfilter == SHOW_RSBS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RSBS) ||
345 #if CONFIG_TUNER
346 (*c->dirfilter == SHOW_RFMS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RFMS) ||
347 #endif
348 #endif
349 #if CONFIG_TUNER
350 (*c->dirfilter == SHOW_FMR && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FMR) ||
351 #endif
352 (*c->dirfilter == SHOW_M3U && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) ||
353 (*c->dirfilter == SHOW_CFG && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_CFG) ||
354 (*c->dirfilter == SHOW_LNG && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_LNG) ||
355 (*c->dirfilter == SHOW_MOD && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_MOD) ||
356 (*c->dirfilter == SHOW_PLUGINS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_ROCK &&
357 (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_LUA) ||
358 (callback_show_item && !callback_show_item(entry->d_name, dptr->attr, c)))
360 continue;
363 if ((len > c->cache.name_buffer_size - name_buffer_used - 1) ||
364 (files_in_dir >= c->cache.max_entries)) {
365 /* Tell the world that we ran out of buffer space */
366 c->dirfull = true;
367 break;
370 ++files_in_dir;
372 dptr->name = &c->cache.name_buffer[name_buffer_used];
373 dptr->time_write =
374 (long)info.wrtdate<<16 |
375 (long)info.wrttime; /* in one # */
376 strcpy(dptr->name, (char *)entry->d_name);
377 name_buffer_used += len + 1;
379 if (dptr->attr & ATTR_DIRECTORY) /* count the remaining dirs */
380 c->dirsindir++;
382 c->filesindir = files_in_dir;
383 c->dirlength = files_in_dir;
384 closedir(dir);
386 compare_sort_dir = c->sort_dir;
387 qsort(c->cache.entries, files_in_dir, sizeof(struct entry), compare);
389 /* If thumbnail talking is enabled, make an extra run to mark files with
390 associated thumbnails, so we don't do unsuccessful spinups later. */
391 if (global_settings.talk_file_clip)
392 check_file_thumbnails(c); /* map .talk to ours */
394 return 0;
396 #ifdef HAVE_LCD_BITMAP
397 static void ft_load_font(char *file)
399 #if NB_SCREENS > 1
400 MENUITEM_STRINGLIST(menu, ID2P(LANG_CUSTOM_FONT), NULL,
401 ID2P(LANG_MAIN_SCREEN), ID2P(LANG_REMOTE_SCREEN))
402 switch (do_menu(&menu, NULL, NULL, false))
404 case 0: /* main lcd */
405 splash(0, ID2P(LANG_WAIT));
406 font_load(NULL, file);
407 set_file(file, (char *)global_settings.font_file, MAX_FILENAME);
408 break;
409 case 1: /* remote */
410 splash(0, ID2P(LANG_WAIT));
411 font_load_remoteui(file);
412 set_file(file, (char *)global_settings.remote_font_file, MAX_FILENAME);
413 break;
415 #else
416 splash(0, ID2P(LANG_WAIT));
417 font_load(NULL, file);
418 set_file(file, (char *)global_settings.font_file, MAX_FILENAME);
419 #endif
421 #endif
423 int ft_enter(struct tree_context* c)
425 int rc = GO_TO_PREVIOUS;
426 char buf[MAX_PATH];
427 struct entry* table = c->cache.entries;
428 struct entry *file = &table[c->selected_item];
430 if (c->currdir[1])
431 snprintf(buf,sizeof(buf),"%s/%s",c->currdir, file->name);
432 else
433 snprintf(buf,sizeof(buf),"/%s",file->name);
435 if (file->attr & ATTR_DIRECTORY) {
436 memcpy(c->currdir, buf, sizeof(c->currdir));
437 if ( c->dirlevel < MAX_DIR_LEVELS )
438 c->selected_item_history[c->dirlevel] = c->selected_item;
439 c->dirlevel++;
440 c->selected_item=0;
442 else {
443 int seed = current_tick;
444 bool play = false;
445 int start_index=0;
447 switch ( file->attr & FILE_ATTR_MASK ) {
448 case FILE_ATTR_M3U:
449 if (!bookmark_autoload(buf))
450 playlist_viewer_ex(buf);
451 break;
453 case FILE_ATTR_AUDIO:
454 if (bookmark_autoload(c->currdir))
455 break;
457 splash(0, ID2P(LANG_WAIT));
459 /* about to create a new current playlist...
460 allow user to cancel the operation */
461 if (!warn_on_pl_erase())
462 break;
464 if (global_settings.party_mode && audio_status())
466 playlist_insert_track(NULL, buf,
467 PLAYLIST_INSERT_LAST, true, true);
468 splash(HZ, ID2P(LANG_QUEUE_LAST));
470 else if (playlist_create(c->currdir, NULL) != -1)
472 start_index = ft_build_playlist(c, c->selected_item);
473 if (global_settings.playlist_shuffle)
475 start_index = playlist_shuffle(seed, start_index);
477 /* when shuffling dir.: play all files
478 even if the file selected by user is
479 not the first one */
480 if (!global_settings.play_selected)
481 start_index = 0;
484 playlist_start(start_index, 0);
485 play = true;
487 break;
489 #if CONFIG_TUNER
490 /* fmr preset file */
491 case FILE_ATTR_FMR:
492 splash(0, ID2P(LANG_WAIT));
494 /* Preset inside the default folder. */
495 if(!strncasecmp(FMPRESET_PATH, buf, strlen(FMPRESET_PATH)))
497 set_file(buf, global_settings.fmr_file, MAX_FILENAME);
498 radio_load_presets(global_settings.fmr_file);
501 * Preset outside default folder, we can choose such only
502 * if we are out of the radio screen, so the check for the
503 * radio status isn't neccessary
505 else
507 radio_load_presets(buf);
509 rc = GO_TO_FM;
511 break;
512 case FILE_ATTR_FMS:
513 splash(0, ID2P(LANG_WAIT));
514 set_file(buf, (char *)global_settings.fms_file, MAX_FILENAME);
515 settings_apply_skins();
516 break;
517 #ifdef HAVE_REMOTE_LCD
518 case FILE_ATTR_RFMS:
519 splash(0, ID2P(LANG_WAIT));
520 set_file(buf, (char *)global_settings.rfms_file, MAX_FILENAME);
521 settings_apply_skins();
522 break;
523 #endif
524 #endif
526 #ifdef HAVE_LCD_BITMAP
527 case FILE_ATTR_SBS:
528 splash(0, ID2P(LANG_WAIT));
529 set_file(buf, (char *)global_settings.sbs_file, MAX_FILENAME);
530 settings_apply_skins();
531 break;
532 #endif
533 #ifdef HAVE_REMOTE_LCD
534 case FILE_ATTR_RSBS:
535 splash(0, ID2P(LANG_WAIT));
536 set_file(buf, (char *)global_settings.rsbs_file, MAX_FILENAME);
537 settings_apply_skins();
538 break;
539 #endif
540 /* wps config file */
541 case FILE_ATTR_WPS:
542 splash(0, ID2P(LANG_WAIT));
543 set_file(buf, (char *)global_settings.wps_file,
544 MAX_FILENAME);
545 settings_apply_skins();
546 break;
548 #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
549 /* remote-wps config file */
550 case FILE_ATTR_RWPS:
551 splash(0, ID2P(LANG_WAIT));
552 set_file(buf, (char *)global_settings.rwps_file,
553 MAX_FILENAME);
554 settings_apply_skins();
555 break;
556 #endif
558 case FILE_ATTR_CFG:
559 splash(0, ID2P(LANG_WAIT));
560 if (!settings_load_config(buf,true))
561 break;
562 splash(HZ, ID2P(LANG_SETTINGS_LOADED));
563 break;
565 case FILE_ATTR_BMARK:
566 splash(0, ID2P(LANG_WAIT));
567 bookmark_load(buf, false);
568 rc = GO_TO_FILEBROWSER;
569 break;
571 case FILE_ATTR_LNG:
572 splash(0, ID2P(LANG_WAIT));
573 if (lang_core_load(buf))
575 splash(HZ, ID2P(LANG_FAILED));
576 break;
578 set_file(buf, (char *)global_settings.lang_file,
579 MAX_FILENAME);
580 talk_init(); /* use voice of same language */
581 viewportmanager_theme_changed(THEME_LANGUAGE);
582 settings_apply_skins();
583 splash(HZ, ID2P(LANG_LANGUAGE_LOADED));
584 break;
586 #ifdef HAVE_LCD_BITMAP
587 case FILE_ATTR_FONT:
588 ft_load_font(buf);
589 break;
591 case FILE_ATTR_KBD:
592 splash(0, ID2P(LANG_WAIT));
593 if (!load_kbd(buf))
594 splash(HZ, ID2P(LANG_KEYBOARD_LOADED));
595 set_file(buf, (char *)global_settings.kbd_file, MAX_FILENAME);
596 break;
597 #endif
599 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
600 /* firmware file */
601 case FILE_ATTR_MOD:
602 splash(0, ID2P(LANG_WAIT));
603 audio_hard_stop();
604 rolo_load(buf);
605 break;
606 #endif
608 /* plugin file */
609 case FILE_ATTR_ROCK:
610 case FILE_ATTR_LUA:
612 char *plugin = buf, *argument = NULL, lua_path[MAX_PATH];
613 int ret;
615 if ((file->attr & FILE_ATTR_MASK) == FILE_ATTR_LUA) {
616 snprintf(lua_path, sizeof(lua_path)-1, "%s/lua.rock", VIEWERS_DIR); /* Use a #define here ? */
617 plugin = lua_path;
618 argument = buf;
621 if (global_settings.party_mode && audio_status()) {
622 splash(HZ, ID2P(LANG_PARTY_MODE));
623 break;
625 ret = plugin_load(plugin, argument);
626 switch (ret)
628 case PLUGIN_GOTO_WPS:
629 play = true;
630 break;
631 case PLUGIN_USB_CONNECTED:
632 if(*c->dirfilter > NUM_FILTER_MODES)
633 /* leave sub-browsers after usb, doing
634 otherwise might be confusing to the user */
635 rc = GO_TO_ROOT;
636 else
637 rc = GO_TO_FILEBROWSER;
638 break;
640 case PLUGIN_ERROR:
641 case PLUGIN_OK:
643 default:
644 break;
646 break;
648 case FILE_ATTR_CUE:
649 display_cuesheet_content(buf);
650 break;
652 default:
654 const char* plugin;
656 if (global_settings.party_mode && audio_status()) {
657 splash(HZ, ID2P(LANG_PARTY_MODE));
658 break;
661 plugin = filetype_get_plugin(file);
662 if (plugin)
664 switch (plugin_load(plugin,buf))
666 case PLUGIN_USB_CONNECTED:
667 rc = GO_TO_FILEBROWSER;
668 break;
669 case PLUGIN_GOTO_WPS:
670 rc = GO_TO_WPS;
671 break;
673 case PLUGIN_OK:
674 case PLUGIN_ERROR:
676 default:
677 break;
680 break;
684 if ( play ) {
685 /* the resume_index must always be the index in the
686 shuffled list in case shuffle is enabled */
687 global_status.resume_index = start_index;
688 global_status.resume_offset = 0;
689 status_save();
690 rc = GO_TO_WPS;
692 else {
693 if (*c->dirfilter > NUM_FILTER_MODES &&
694 *c->dirfilter != SHOW_CFG &&
695 *c->dirfilter != SHOW_FONT &&
696 *c->dirfilter != SHOW_PLUGINS)
698 rc = GO_TO_ROOT;
702 return rc;
705 int ft_exit(struct tree_context* c)
707 extern char lastfile[]; /* from tree.c */
708 char buf[MAX_PATH];
709 int rc = 0;
710 bool exit_func = false;
712 int i = strlen(c->currdir);
713 if (i>1) {
714 while (c->currdir[i-1]!='/')
715 i--;
716 strcpy(buf,&c->currdir[i]);
717 if (i==1)
718 c->currdir[i]=0;
719 else
720 c->currdir[i-1]=0;
722 if (*c->dirfilter > NUM_FILTER_MODES && c->dirlevel < 1)
723 exit_func = true;
725 c->dirlevel--;
726 if ( c->dirlevel < MAX_DIR_LEVELS )
727 c->selected_item=c->selected_item_history[c->dirlevel];
728 else
729 c->selected_item=0;
731 /* if undefined position */
732 if (c->selected_item == -1)
733 strcpy(lastfile, buf);
735 else
737 if (*c->dirfilter > NUM_FILTER_MODES && c->dirlevel < 1)
738 exit_func = true;
741 if (exit_func)
742 rc = 3;
744 return rc;