Hopefully get shutdown/exit handling on SDL/maemo right.
[maemo-rb.git] / apps / filetree.c
blob96fcc8a1e79cec60054748517974256af4046790
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 #ifdef HAVE_LCD_BITMAP
47 #include "keyboard.h"
48 #endif
50 #if CONFIG_TUNER
51 #include "radio.h"
52 #endif
53 #include "wps.h"
55 static int compare_sort_dir; /* qsort key for sorting directories */
57 int ft_build_playlist(struct tree_context* c, int start_index)
59 int i;
60 int start=start_index;
62 struct entry *dircache = c->dircache;
64 for(i = 0;i < c->filesindir;i++)
66 if((dircache[i].attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO)
68 if (playlist_add(dircache[i].name) < 0)
69 break;
71 else
73 /* Adjust the start index when se skip non-MP3 entries */
74 if(i < start)
75 start_index--;
79 return start_index;
82 /* Start playback of a playlist, checking for bookmark autoload, modified
83 * playlists, etc., as required. Returns false if playback wasn't started,
84 * or started via bookmark autoload, true otherwise.
86 * Pointers to both the full pathname and the separated parts needed to
87 * avoid allocating yet another path buffer on the stack (and save some
88 * code; the caller typically needs to create the full pathname anyway)...
90 bool ft_play_playlist(char* pathname, char* dirname, char* filename)
92 if (global_settings.party_mode && audio_status())
94 splash(HZ, ID2P(LANG_PARTY_MODE));
95 return false;
98 if (bookmark_autoload(pathname))
100 return false;
103 splash(0, ID2P(LANG_WAIT));
105 /* about to create a new current playlist...
106 allow user to cancel the operation */
107 if (!warn_on_pl_erase())
108 return false;
110 if (playlist_create(dirname, filename) != -1)
112 if (global_settings.playlist_shuffle)
114 playlist_shuffle(current_tick, -1);
117 playlist_start(0, 0);
118 return true;
121 return false;
124 /* walk a directory and check all dircache entries if a .talk file exists */
125 static void check_file_thumbnails(struct tree_context* c)
127 int i;
128 struct dirent *entry;
129 struct entry* dircache = c->dircache;
130 DIR *dir;
132 dir = opendir(c->currdir);
133 if(!dir)
134 return;
135 /* mark all files as non talking, except the .talk ones */
136 for (i=0; i < c->filesindir; i++)
138 if (dircache[i].attr & ATTR_DIRECTORY)
139 continue; /* we're not touching directories */
141 if (strcasecmp(file_thumbnail_ext,
142 &dircache[i].name[strlen(dircache[i].name)
143 - strlen(file_thumbnail_ext)]))
144 { /* no .talk file */
145 dircache[i].attr &= ~FILE_ATTR_THUMBNAIL; /* clear */
147 else
148 { /* .talk file, we later let them speak themselves */
149 dircache[i].attr |= FILE_ATTR_THUMBNAIL; /* set */
153 while((entry = readdir(dir)) != 0) /* walk directory */
155 int ext_pos;
156 struct dirinfo info = dir_get_info(dir, entry);
157 ext_pos = strlen((char *)entry->d_name) - strlen(file_thumbnail_ext);
158 if (ext_pos <= 0 /* too short to carry ".talk" */
159 || (info.attribute & ATTR_DIRECTORY) /* no file */
160 || strcasecmp((char *)&entry->d_name[ext_pos], file_thumbnail_ext))
161 { /* or doesn't end with ".talk", no candidate */
162 continue;
165 /* terminate the (disposable) name in dir buffer,
166 this truncates off the ".talk" without needing an extra buffer */
167 entry->d_name[ext_pos] = '\0';
169 /* search corresponding file in dir cache */
170 for (i=0; i < c->filesindir; i++)
172 if (!strcasecmp(dircache[i].name, (char *)entry->d_name))
173 { /* match */
174 dircache[i].attr |= FILE_ATTR_THUMBNAIL; /* set the flag */
175 break; /* exit search loop, because we found it */
179 closedir(dir);
182 /* support function for qsort() */
183 static int compare(const void* p1, const void* p2)
185 struct entry* e1 = (struct entry*)p1;
186 struct entry* e2 = (struct entry*)p2;
187 int criteria;
189 if (e1->attr & ATTR_DIRECTORY && e2->attr & ATTR_DIRECTORY)
190 { /* two directories */
191 criteria = compare_sort_dir;
193 #ifdef HAVE_MULTIVOLUME
194 if (e1->attr & ATTR_VOLUME || e2->attr & ATTR_VOLUME)
195 { /* a volume identifier is involved */
196 if (e1->attr & ATTR_VOLUME && e2->attr & ATTR_VOLUME)
197 criteria = SORT_ALPHA; /* two volumes: sort alphabetically */
198 else /* only one is a volume: volume first */
199 return (e2->attr & ATTR_VOLUME) - (e1->attr & ATTR_VOLUME);
201 #endif
204 else if (!(e1->attr & ATTR_DIRECTORY) && !(e2->attr & ATTR_DIRECTORY))
205 { /* two files */
206 criteria = global_settings.sort_file;
208 else /* dir and file, dir goes first */
209 return (e2->attr & ATTR_DIRECTORY) - (e1->attr & ATTR_DIRECTORY);
211 switch(criteria)
213 case SORT_TYPE:
214 case SORT_TYPE_REVERSED:
216 int t1 = e1->attr & FILE_ATTR_MASK;
217 int t2 = e2->attr & FILE_ATTR_MASK;
219 if (!t1) /* unknown type */
220 t1 = INT_MAX; /* gets a high number, to sort after known */
221 if (!t2) /* unknown type */
222 t2 = INT_MAX; /* gets a high number, to sort after known */
224 if (t1 != t2) /* if different */
225 return (t1 - t2) * (criteria == SORT_TYPE_REVERSED ? -1 : 1);
226 /* else fall through to alphabetical sorting */
229 case SORT_DATE:
230 case SORT_DATE_REVERSED:
231 /* Ignore SORT_TYPE */
232 if (criteria == SORT_DATE || criteria == SORT_DATE_REVERSED)
234 if (e1->time_write != e2->time_write)
235 return (e1->time_write - e2->time_write)
236 * (criteria == SORT_DATE_REVERSED ? -1 : 1);
237 /* else fall through to alphabetical sorting */
240 case SORT_ALPHA:
241 case SORT_ALPHA_REVERSED:
243 if (global_settings.sort_case)
245 if (global_settings.interpret_numbers == SORT_INTERPRET_AS_NUMBER)
246 return strnatcmp(e1->name, e2->name)
247 * (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
248 else
249 return strncmp(e1->name, e2->name, MAX_PATH)
250 * (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
252 else
254 if (global_settings.interpret_numbers == SORT_INTERPRET_AS_NUMBER)
255 return strnatcasecmp(e1->name, e2->name)
256 * (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
257 else
258 return strncasecmp(e1->name, e2->name, MAX_PATH)
259 * (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
264 return 0; /* never reached */
267 /* load and sort directory into dircache. returns NULL on failure. */
268 int ft_load(struct tree_context* c, const char* tempdir)
270 int i;
271 int name_buffer_used = 0;
272 bool (*callback_show_item)(char *, int, struct tree_context *) = NULL;
273 DIR *dir;
275 if (tempdir)
276 dir = opendir(tempdir);
277 else
279 dir = opendir(c->currdir);
280 callback_show_item = c->browse? c->browse->callback_show_item: NULL;
282 if(!dir)
283 return -1; /* not a directory */
285 c->dirsindir = 0;
286 c->dirfull = false;
288 for ( i=0; i < global_settings.max_files_in_dir; i++ ) {
289 int len;
290 struct dirent *entry = readdir(dir);
291 struct dirinfo info;
292 struct entry* dptr =
293 (struct entry*)(c->dircache + i * sizeof(struct entry));
294 if (!entry)
295 break;
297 info = dir_get_info(dir, entry);
298 len = strlen((char *)entry->d_name);
300 /* skip directories . and .. */
301 if ((info.attribute & ATTR_DIRECTORY) &&
302 (((len == 1) && (!strncmp((char *)entry->d_name, ".", 1))) ||
303 ((len == 2) && (!strncmp((char *)entry->d_name, "..", 2))))) {
304 i--;
305 continue;
308 /* Skip FAT volume ID */
309 if (info.attribute & ATTR_VOLUME_ID) {
310 i--;
311 continue;
314 /* filter out dotfiles and hidden files */
315 if (*c->dirfilter != SHOW_ALL &&
316 ((entry->d_name[0]=='.') ||
317 (info.attribute & ATTR_HIDDEN))) {
318 i--;
319 continue;
322 dptr->attr = info.attribute;
324 /* check for known file types */
325 if ( !(dptr->attr & ATTR_DIRECTORY) )
326 dptr->attr |= filetype_get_attr((char *)entry->d_name);
328 /* filter out non-visible files */
329 if ((!(dptr->attr & ATTR_DIRECTORY) && (
330 (*c->dirfilter == SHOW_PLAYLIST &&
331 (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) ||
332 ((*c->dirfilter == SHOW_MUSIC &&
333 (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) &&
334 (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) ||
335 (*c->dirfilter == SHOW_SUPPORTED && !filetype_supported(dptr->attr)))) ||
336 (*c->dirfilter == SHOW_WPS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_WPS) ||
337 #ifdef HAVE_LCD_BITMAP
338 (*c->dirfilter == SHOW_FONT && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FONT) ||
339 (*c->dirfilter == SHOW_SBS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_SBS) ||
340 #if CONFIG_TUNER
341 (*c->dirfilter == SHOW_FMS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FMS) ||
342 #endif
343 #endif
344 #ifdef HAVE_REMOTE_LCD
345 (*c->dirfilter == SHOW_RWPS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RWPS) ||
346 (*c->dirfilter == SHOW_RSBS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RSBS) ||
347 #if CONFIG_TUNER
348 (*c->dirfilter == SHOW_RFMS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RFMS) ||
349 #endif
350 #endif
351 #if CONFIG_TUNER
352 (*c->dirfilter == SHOW_FMR && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FMR) ||
353 #endif
354 (*c->dirfilter == SHOW_M3U && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) ||
355 (*c->dirfilter == SHOW_CFG && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_CFG) ||
356 (*c->dirfilter == SHOW_LNG && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_LNG) ||
357 (*c->dirfilter == SHOW_MOD && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_MOD) ||
358 (*c->dirfilter == SHOW_PLUGINS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_ROCK &&
359 (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_LUA) ||
360 (callback_show_item && !callback_show_item(entry->d_name, dptr->attr, c)))
362 i--;
363 continue;
366 if (len > c->name_buffer_size - name_buffer_used - 1) {
367 /* Tell the world that we ran out of buffer space */
368 c->dirfull = true;
369 break;
371 dptr->name = &c->name_buffer[name_buffer_used];
372 dptr->time_write =
373 (long)info.wrtdate<<16 |
374 (long)info.wrttime; /* in one # */
375 strcpy(dptr->name, (char *)entry->d_name);
376 name_buffer_used += len + 1;
378 if (dptr->attr & ATTR_DIRECTORY) /* count the remaining dirs */
379 c->dirsindir++;
381 c->filesindir = i;
382 c->dirlength = i;
383 closedir(dir);
385 compare_sort_dir = c->sort_dir;
386 qsort(c->dircache,i,sizeof(struct entry),compare);
388 /* If thumbnail talking is enabled, make an extra run to mark files with
389 associated thumbnails, so we don't do unsuccessful spinups later. */
390 if (global_settings.talk_file_clip)
391 check_file_thumbnails(c); /* map .talk to ours */
393 return 0;
395 #ifdef HAVE_LCD_BITMAP
396 static void ft_load_font(char *file)
398 #if NB_SCREENS > 1
399 MENUITEM_STRINGLIST(menu, ID2P(LANG_CUSTOM_FONT), NULL,
400 ID2P(LANG_MAIN_SCREEN), ID2P(LANG_REMOTE_SCREEN))
401 switch (do_menu(&menu, NULL, NULL, false))
403 case 0: /* main lcd */
404 splash(0, ID2P(LANG_WAIT));
405 font_load(NULL, file);
406 set_file(file, (char *)global_settings.font_file, MAX_FILENAME);
407 break;
408 case 1: /* remote */
409 splash(0, ID2P(LANG_WAIT));
410 font_load_remoteui(file);
411 set_file(file, (char *)global_settings.remote_font_file, MAX_FILENAME);
412 break;
414 #else
415 splash(0, ID2P(LANG_WAIT));
416 font_load(NULL, file);
417 set_file(file, (char *)global_settings.font_file, MAX_FILENAME);
418 #endif
420 #endif
422 int ft_enter(struct tree_context* c)
424 int rc = GO_TO_PREVIOUS;
425 char buf[MAX_PATH];
426 struct entry *dircache = c->dircache;
427 struct entry* file = &dircache[c->selected_item];
429 if (c->currdir[1])
430 snprintf(buf,sizeof(buf),"%s/%s",c->currdir, file->name);
431 else
432 snprintf(buf,sizeof(buf),"/%s",file->name);
434 if (file->attr & ATTR_DIRECTORY) {
435 memcpy(c->currdir, buf, sizeof(c->currdir));
436 if ( c->dirlevel < MAX_DIR_LEVELS )
437 c->selected_item_history[c->dirlevel] = c->selected_item;
438 c->dirlevel++;
439 c->selected_item=0;
441 else {
442 int seed = current_tick;
443 bool play = false;
444 int start_index=0;
446 switch ( file->attr & FILE_ATTR_MASK ) {
447 case FILE_ATTR_M3U:
448 play = ft_play_playlist(buf, c->currdir, file->name);
450 if (play)
452 start_index = 0;
455 break;
457 case FILE_ATTR_AUDIO:
458 if (bookmark_autoload(c->currdir))
459 break;
461 splash(0, ID2P(LANG_WAIT));
463 /* about to create a new current playlist...
464 allow user to cancel the operation */
465 if (!warn_on_pl_erase())
466 break;
468 if (global_settings.party_mode && audio_status())
470 playlist_insert_track(NULL, buf,
471 PLAYLIST_INSERT_LAST, true, true);
472 splash(HZ, ID2P(LANG_QUEUE_LAST));
474 else if (playlist_create(c->currdir, NULL) != -1)
476 start_index = ft_build_playlist(c, c->selected_item);
477 if (global_settings.playlist_shuffle)
479 start_index = playlist_shuffle(seed, start_index);
481 /* when shuffling dir.: play all files
482 even if the file selected by user is
483 not the first one */
484 if (!global_settings.play_selected)
485 start_index = 0;
488 playlist_start(start_index, 0);
489 play = true;
491 break;
493 #if CONFIG_TUNER
494 /* fmr preset file */
495 case FILE_ATTR_FMR:
496 splash(0, ID2P(LANG_WAIT));
498 /* Preset inside the default folder. */
499 if(!strncasecmp(FMPRESET_PATH, buf, strlen(FMPRESET_PATH)))
501 set_file(buf, global_settings.fmr_file, MAX_FILENAME);
502 radio_load_presets(global_settings.fmr_file);
505 * Preset outside default folder, we can choose such only
506 * if we are out of the radio screen, so the check for the
507 * radio status isn't neccessary
509 else
511 radio_load_presets(buf);
513 rc = GO_TO_FM;
515 break;
516 case FILE_ATTR_FMS:
517 splash(0, ID2P(LANG_WAIT));
518 set_file(buf, (char *)global_settings.fms_file, MAX_FILENAME);
519 settings_apply_skins();
520 break;
521 #ifdef HAVE_REMOTE_LCD
522 case FILE_ATTR_RFMS:
523 splash(0, ID2P(LANG_WAIT));
524 set_file(buf, (char *)global_settings.rfms_file, MAX_FILENAME);
525 settings_apply_skins();
526 break;
527 #endif
528 #endif
530 #ifdef HAVE_LCD_BITMAP
531 case FILE_ATTR_SBS:
532 splash(0, ID2P(LANG_WAIT));
533 set_file(buf, (char *)global_settings.sbs_file, MAX_FILENAME);
534 settings_apply_skins();
535 break;
536 #endif
537 #ifdef HAVE_REMOTE_LCD
538 case FILE_ATTR_RSBS:
539 splash(0, ID2P(LANG_WAIT));
540 set_file(buf, (char *)global_settings.rsbs_file, MAX_FILENAME);
541 settings_apply_skins();
542 break;
543 #endif
544 /* wps config file */
545 case FILE_ATTR_WPS:
546 splash(0, ID2P(LANG_WAIT));
547 set_file(buf, (char *)global_settings.wps_file,
548 MAX_FILENAME);
549 settings_apply_skins();
550 break;
552 #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
553 /* remote-wps config file */
554 case FILE_ATTR_RWPS:
555 splash(0, ID2P(LANG_WAIT));
556 set_file(buf, (char *)global_settings.rwps_file,
557 MAX_FILENAME);
558 settings_apply_skins();
559 break;
560 #endif
562 case FILE_ATTR_CFG:
563 splash(0, ID2P(LANG_WAIT));
564 if (!settings_load_config(buf,true))
565 break;
566 splash(HZ, ID2P(LANG_SETTINGS_LOADED));
567 break;
569 case FILE_ATTR_BMARK:
570 splash(0, ID2P(LANG_WAIT));
571 bookmark_load(buf, false);
572 rc = GO_TO_FILEBROWSER;
573 break;
575 case FILE_ATTR_LNG:
576 splash(0, ID2P(LANG_WAIT));
577 if (lang_core_load(buf))
579 splash(HZ, ID2P(LANG_FAILED));
580 break;
582 set_file(buf, (char *)global_settings.lang_file,
583 MAX_FILENAME);
584 talk_init(); /* use voice of same language */
585 viewportmanager_theme_changed(THEME_LANGUAGE);
586 settings_apply_skins();
587 splash(HZ, ID2P(LANG_LANGUAGE_LOADED));
588 break;
590 #ifdef HAVE_LCD_BITMAP
591 case FILE_ATTR_FONT:
592 ft_load_font(buf);
593 break;
595 case FILE_ATTR_KBD:
596 splash(0, ID2P(LANG_WAIT));
597 if (!load_kbd(buf))
598 splash(HZ, ID2P(LANG_KEYBOARD_LOADED));
599 set_file(buf, (char *)global_settings.kbd_file, MAX_FILENAME);
600 break;
601 #endif
603 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
604 /* firmware file */
605 case FILE_ATTR_MOD:
606 splash(0, ID2P(LANG_WAIT));
607 rolo_load(buf);
608 break;
609 #endif
611 /* plugin file */
612 case FILE_ATTR_ROCK:
613 case FILE_ATTR_LUA:
615 char *plugin = buf, *argument = NULL, lua_path[MAX_PATH];
616 int ret;
618 if ((file->attr & FILE_ATTR_MASK) == FILE_ATTR_LUA) {
619 snprintf(lua_path, sizeof(lua_path)-1, "%s/lua.rock", VIEWERS_DIR); /* Use a #define here ? */
620 plugin = lua_path;
621 argument = buf;
624 if (global_settings.party_mode && audio_status()) {
625 splash(HZ, ID2P(LANG_PARTY_MODE));
626 break;
628 ret = plugin_load(plugin, argument);
629 switch (ret)
631 case PLUGIN_GOTO_WPS:
632 play = true;
633 break;
634 case PLUGIN_USB_CONNECTED:
635 if(*c->dirfilter > NUM_FILTER_MODES)
636 /* leave sub-browsers after usb, doing
637 otherwise might be confusing to the user */
638 rc = GO_TO_ROOT;
639 else
640 rc = GO_TO_FILEBROWSER;
641 break;
643 case PLUGIN_ERROR:
644 case PLUGIN_OK:
646 default:
647 break;
649 break;
651 case FILE_ATTR_CUE:
652 display_cuesheet_content(buf);
653 break;
655 default:
657 const char* plugin;
659 if (global_settings.party_mode && audio_status()) {
660 splash(HZ, ID2P(LANG_PARTY_MODE));
661 break;
664 plugin = filetype_get_plugin(file);
665 if (plugin)
667 switch (plugin_load(plugin,buf))
669 case PLUGIN_USB_CONNECTED:
670 rc = GO_TO_FILEBROWSER;
671 break;
672 case PLUGIN_GOTO_WPS:
673 rc = GO_TO_WPS;
674 break;
676 case PLUGIN_OK:
677 case PLUGIN_ERROR:
679 default:
680 break;
683 break;
687 if ( play ) {
688 /* the resume_index must always be the index in the
689 shuffled list in case shuffle is enabled */
690 global_status.resume_index = start_index;
691 global_status.resume_offset = 0;
692 status_save();
693 rc = GO_TO_WPS;
695 else {
696 if (*c->dirfilter > NUM_FILTER_MODES &&
697 *c->dirfilter != SHOW_CFG &&
698 *c->dirfilter != SHOW_FONT &&
699 *c->dirfilter != SHOW_PLUGINS)
701 rc = GO_TO_ROOT;
705 return rc;
708 int ft_exit(struct tree_context* c)
710 extern char lastfile[]; /* from tree.c */
711 char buf[MAX_PATH];
712 int rc = 0;
713 bool exit_func = false;
715 int i = strlen(c->currdir);
716 if (i>1) {
717 while (c->currdir[i-1]!='/')
718 i--;
719 strcpy(buf,&c->currdir[i]);
720 if (i==1)
721 c->currdir[i]=0;
722 else
723 c->currdir[i-1]=0;
725 if (*c->dirfilter > NUM_FILTER_MODES && c->dirlevel < 1)
726 exit_func = true;
728 c->dirlevel--;
729 if ( c->dirlevel < MAX_DIR_LEVELS )
730 c->selected_item=c->selected_item_history[c->dirlevel];
731 else
732 c->selected_item=0;
734 /* if undefined position */
735 if (c->selected_item == -1)
736 strcpy(lastfile, buf);
738 else
740 if (*c->dirfilter > NUM_FILTER_MODES && c->dirlevel < 1)
741 exit_func = true;
744 if (exit_func)
745 rc = 3;
747 return rc;