Fix hwcodec red.
[maemo-rb.git] / apps / filetree.c
blob35bb2a8fd08efe7989787f631f2e7ed6699b0dde
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 "core_alloc.h"
33 #include "settings.h"
34 #include "filetypes.h"
35 #include "talk.h"
36 #include "playlist.h"
37 #include "lang.h"
38 #include "language.h"
39 #include "screens.h"
40 #include "plugin.h"
41 #include "rolo.h"
42 #include "splash.h"
43 #include "cuesheet.h"
44 #include "filetree.h"
45 #include "misc.h"
46 #include "strnatcmp.h"
47 #include "playlist_viewer.h"
48 #ifdef HAVE_LCD_BITMAP
49 #include "keyboard.h"
50 #endif
52 #if CONFIG_TUNER
53 #include "radio.h"
54 #endif
55 #include "wps.h"
57 static int compare_sort_dir; /* qsort key for sorting directories */
59 int ft_build_playlist(struct tree_context* c, int start_index)
61 int i;
62 int start=start_index;
64 tree_lock_cache(c);
65 struct entry *entries = tree_get_entries(c);
67 for(i = 0;i < c->filesindir;i++)
69 if((entries[i].attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO)
71 if (playlist_add(entries[i].name) < 0)
72 break;
74 else
76 /* Adjust the start index when se skip non-MP3 entries */
77 if(i < start)
78 start_index--;
82 tree_unlock_cache(c);
84 return start_index;
87 /* Start playback of a playlist, checking for bookmark autoload, modified
88 * playlists, etc., as required. Returns false if playback wasn't started,
89 * or started via bookmark autoload, true otherwise.
91 * Pointers to both the full pathname and the separated parts needed to
92 * avoid allocating yet another path buffer on the stack (and save some
93 * code; the caller typically needs to create the full pathname anyway)...
95 bool ft_play_playlist(char* pathname, char* dirname, char* filename)
97 if (global_settings.party_mode && audio_status())
99 splash(HZ, ID2P(LANG_PARTY_MODE));
100 return false;
103 if (bookmark_autoload(pathname))
105 return false;
108 splash(0, ID2P(LANG_WAIT));
110 /* about to create a new current playlist...
111 allow user to cancel the operation */
112 if (!warn_on_pl_erase())
113 return false;
115 if (playlist_create(dirname, filename) != -1)
117 if (global_settings.playlist_shuffle)
119 playlist_shuffle(current_tick, -1);
122 playlist_start(0, 0);
123 return true;
126 return false;
129 /* walk a directory and check all entries if a .talk file exists */
130 static void check_file_thumbnails(struct tree_context* c)
132 int i;
133 struct dirent *entry;
134 struct entry* entries;
135 DIR *dir;
137 dir = opendir(c->currdir);
138 if(!dir)
139 return;
140 /* mark all files as non talking, except the .talk ones */
141 entries = tree_get_entries(c);
142 tree_lock_cache(c);
143 for (i=0; i < c->filesindir; i++)
145 if (entries[i].attr & ATTR_DIRECTORY)
146 continue; /* we're not touching directories */
148 if (strcasecmp(file_thumbnail_ext,
149 &entries[i].name[strlen(entries[i].name)
150 - strlen(file_thumbnail_ext)]))
151 { /* no .talk file */
152 entries[i].attr &= ~FILE_ATTR_THUMBNAIL; /* clear */
154 else
155 { /* .talk file, we later let them speak themselves */
156 entries[i].attr |= FILE_ATTR_THUMBNAIL; /* set */
160 while((entry = readdir(dir)) != 0) /* walk directory */
162 int ext_pos;
163 struct dirinfo info = dir_get_info(dir, entry);
164 ext_pos = strlen((char *)entry->d_name) - strlen(file_thumbnail_ext);
165 if (ext_pos <= 0 /* too short to carry ".talk" */
166 || (info.attribute & ATTR_DIRECTORY) /* no file */
167 || strcasecmp((char *)&entry->d_name[ext_pos], file_thumbnail_ext))
168 { /* or doesn't end with ".talk", no candidate */
169 continue;
172 /* terminate the (disposable) name in dir buffer,
173 this truncates off the ".talk" without needing an extra buffer */
174 entry->d_name[ext_pos] = '\0';
176 /* search corresponding file in dir cache */
177 for (i=0; i < c->filesindir; i++)
179 if (!strcasecmp(entries[i].name, (char *)entry->d_name))
180 { /* match */
181 entries[i].attr |= FILE_ATTR_THUMBNAIL; /* set the flag */
182 break; /* exit search loop, because we found it */
186 tree_unlock_cache(c);
187 closedir(dir);
190 /* support function for qsort() */
191 static int compare(const void* p1, const void* p2)
193 struct entry* e1 = (struct entry*)p1;
194 struct entry* e2 = (struct entry*)p2;
195 int criteria;
197 if (e1->attr & ATTR_DIRECTORY && e2->attr & ATTR_DIRECTORY)
198 { /* two directories */
199 criteria = compare_sort_dir;
201 #ifdef HAVE_MULTIVOLUME
202 if (e1->attr & ATTR_VOLUME || e2->attr & ATTR_VOLUME)
203 { /* a volume identifier is involved */
204 if (e1->attr & ATTR_VOLUME && e2->attr & ATTR_VOLUME)
205 criteria = SORT_ALPHA; /* two volumes: sort alphabetically */
206 else /* only one is a volume: volume first */
207 return (e2->attr & ATTR_VOLUME) - (e1->attr & ATTR_VOLUME);
209 #endif
212 else if (!(e1->attr & ATTR_DIRECTORY) && !(e2->attr & ATTR_DIRECTORY))
213 { /* two files */
214 criteria = global_settings.sort_file;
216 else /* dir and file, dir goes first */
217 return (e2->attr & ATTR_DIRECTORY) - (e1->attr & ATTR_DIRECTORY);
219 switch(criteria)
221 case SORT_TYPE:
222 case SORT_TYPE_REVERSED:
224 int t1 = e1->attr & FILE_ATTR_MASK;
225 int t2 = e2->attr & FILE_ATTR_MASK;
227 if (!t1) /* unknown type */
228 t1 = INT_MAX; /* gets a high number, to sort after known */
229 if (!t2) /* unknown type */
230 t2 = INT_MAX; /* gets a high number, to sort after known */
232 if (t1 != t2) /* if different */
233 return (t1 - t2) * (criteria == SORT_TYPE_REVERSED ? -1 : 1);
234 /* else fall through to alphabetical sorting */
237 case SORT_DATE:
238 case SORT_DATE_REVERSED:
239 /* Ignore SORT_TYPE */
240 if (criteria == SORT_DATE || criteria == SORT_DATE_REVERSED)
242 if (e1->time_write != e2->time_write)
243 return (e1->time_write - e2->time_write)
244 * (criteria == SORT_DATE_REVERSED ? -1 : 1);
245 /* else fall through to alphabetical sorting */
248 case SORT_ALPHA:
249 case SORT_ALPHA_REVERSED:
251 if (global_settings.sort_case)
253 if (global_settings.interpret_numbers == SORT_INTERPRET_AS_NUMBER)
254 return strnatcmp(e1->name, e2->name)
255 * (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
256 else
257 return strncmp(e1->name, e2->name, MAX_PATH)
258 * (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
260 else
262 if (global_settings.interpret_numbers == SORT_INTERPRET_AS_NUMBER)
263 return strnatcasecmp(e1->name, e2->name)
264 * (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
265 else
266 return strncasecmp(e1->name, e2->name, MAX_PATH)
267 * (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
272 return 0; /* never reached */
275 /* load and sort directory into the tree's cache. returns NULL on failure. */
276 int ft_load(struct tree_context* c, const char* tempdir)
278 int files_in_dir = 0;
279 int name_buffer_used = 0;
280 struct dirent *entry;
281 bool (*callback_show_item)(char *, int, struct tree_context *) = NULL;
282 DIR *dir;
284 if (tempdir)
285 dir = opendir(tempdir);
286 else
288 dir = opendir(c->currdir);
289 callback_show_item = c->browse? c->browse->callback_show_item: NULL;
291 if(!dir)
292 return -1; /* not a directory */
294 c->dirsindir = 0;
295 c->dirfull = false;
297 tree_lock_cache(c);
298 while ((entry = readdir(dir))) {
299 int len;
300 struct dirinfo info;
301 struct entry* dptr = tree_get_entry_at(c, files_in_dir);
302 if (!entry)
303 break;
305 info = dir_get_info(dir, entry);
306 len = strlen((char *)entry->d_name);
308 /* skip directories . and .. */
309 if ((info.attribute & ATTR_DIRECTORY) &&
310 (((len == 1) && (!strncmp((char *)entry->d_name, ".", 1))) ||
311 ((len == 2) && (!strncmp((char *)entry->d_name, "..", 2))))) {
312 continue;
315 /* Skip FAT volume ID */
316 if (info.attribute & ATTR_VOLUME_ID) {
317 continue;
320 /* filter out dotfiles and hidden files */
321 if (*c->dirfilter != SHOW_ALL &&
322 ((entry->d_name[0]=='.') ||
323 (info.attribute & ATTR_HIDDEN))) {
324 continue;
327 dptr->attr = info.attribute;
329 /* check for known file types */
330 if ( !(dptr->attr & ATTR_DIRECTORY) )
331 dptr->attr |= filetype_get_attr((char *)entry->d_name);
333 /* filter out non-visible files */
334 if ((!(dptr->attr & ATTR_DIRECTORY) && (
335 (*c->dirfilter == SHOW_PLAYLIST &&
336 (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) ||
337 ((*c->dirfilter == SHOW_MUSIC &&
338 (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) &&
339 (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) ||
340 (*c->dirfilter == SHOW_SUPPORTED && !filetype_supported(dptr->attr)))) ||
341 (*c->dirfilter == SHOW_WPS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_WPS) ||
342 #ifdef HAVE_LCD_BITMAP
343 (*c->dirfilter == SHOW_FONT && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FONT) ||
344 (*c->dirfilter == SHOW_SBS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_SBS) ||
345 #if CONFIG_TUNER
346 (*c->dirfilter == SHOW_FMS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FMS) ||
347 #endif
348 #endif
349 #ifdef HAVE_REMOTE_LCD
350 (*c->dirfilter == SHOW_RWPS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RWPS) ||
351 (*c->dirfilter == SHOW_RSBS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RSBS) ||
352 #if CONFIG_TUNER
353 (*c->dirfilter == SHOW_RFMS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RFMS) ||
354 #endif
355 #endif
356 #if CONFIG_TUNER
357 (*c->dirfilter == SHOW_FMR && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FMR) ||
358 #endif
359 (*c->dirfilter == SHOW_M3U && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) ||
360 (*c->dirfilter == SHOW_CFG && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_CFG) ||
361 (*c->dirfilter == SHOW_LNG && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_LNG) ||
362 (*c->dirfilter == SHOW_MOD && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_MOD) ||
363 (*c->dirfilter == SHOW_PLUGINS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_ROCK &&
364 (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_LUA) ||
365 (callback_show_item && !callback_show_item(entry->d_name, dptr->attr, c)))
367 continue;
370 if ((len > c->cache.name_buffer_size - name_buffer_used - 1) ||
371 (files_in_dir >= c->cache.max_entries)) {
372 /* Tell the world that we ran out of buffer space */
373 c->dirfull = true;
374 break;
377 ++files_in_dir;
379 dptr->name = core_get_data(c->cache.name_buffer_handle)+name_buffer_used;
380 dptr->time_write =
381 (long)info.wrtdate<<16 |
382 (long)info.wrttime; /* in one # */
383 strcpy(dptr->name, (char *)entry->d_name);
384 name_buffer_used += len + 1;
386 if (dptr->attr & ATTR_DIRECTORY) /* count the remaining dirs */
387 c->dirsindir++;
389 c->filesindir = files_in_dir;
390 c->dirlength = files_in_dir;
391 closedir(dir);
393 compare_sort_dir = c->sort_dir;
394 qsort(tree_get_entries(c), files_in_dir, sizeof(struct entry), compare);
396 /* If thumbnail talking is enabled, make an extra run to mark files with
397 associated thumbnails, so we don't do unsuccessful spinups later. */
398 if (global_settings.talk_file_clip)
399 check_file_thumbnails(c); /* map .talk to ours */
401 tree_unlock_cache(c);
402 return 0;
404 #ifdef HAVE_LCD_BITMAP
405 static void ft_load_font(char *file)
407 #if NB_SCREENS > 1
408 MENUITEM_STRINGLIST(menu, ID2P(LANG_CUSTOM_FONT), NULL,
409 ID2P(LANG_MAIN_SCREEN), ID2P(LANG_REMOTE_SCREEN))
410 switch (do_menu(&menu, NULL, NULL, false))
412 case 0: /* main lcd */
413 splash(0, ID2P(LANG_WAIT));
414 font_load(NULL, file);
415 set_file(file, (char *)global_settings.font_file, MAX_FILENAME);
416 break;
417 case 1: /* remote */
418 splash(0, ID2P(LANG_WAIT));
419 font_load_remoteui(file);
420 set_file(file, (char *)global_settings.remote_font_file, MAX_FILENAME);
421 break;
423 #else
424 splash(0, ID2P(LANG_WAIT));
425 font_load(NULL, file);
426 set_file(file, (char *)global_settings.font_file, MAX_FILENAME);
427 #endif
429 #endif
431 int ft_enter(struct tree_context* c)
433 int rc = GO_TO_PREVIOUS;
434 char buf[MAX_PATH];
435 struct entry* file = tree_get_entry_at(c, c->selected_item);
436 int file_attr = file->attr;
438 if (c->currdir[1])
439 snprintf(buf,sizeof(buf),"%s/%s",c->currdir, file->name);
440 else
441 snprintf(buf,sizeof(buf),"/%s",file->name);
443 if (file_attr & ATTR_DIRECTORY) {
444 memcpy(c->currdir, buf, sizeof(c->currdir));
445 if ( c->dirlevel < MAX_DIR_LEVELS )
446 c->selected_item_history[c->dirlevel] = c->selected_item;
447 c->dirlevel++;
448 c->selected_item=0;
450 else {
451 int seed = current_tick;
452 bool play = false;
453 int start_index=0;
455 switch ( file_attr & FILE_ATTR_MASK ) {
456 case FILE_ATTR_M3U:
457 if (!bookmark_autoload(buf))
458 playlist_viewer_ex(buf);
459 break;
461 case FILE_ATTR_AUDIO:
462 if (bookmark_autoload(c->currdir))
463 break;
465 splash(0, ID2P(LANG_WAIT));
467 /* about to create a new current playlist...
468 allow user to cancel the operation */
469 if (!warn_on_pl_erase())
470 break;
472 if (global_settings.party_mode && audio_status())
474 playlist_insert_track(NULL, buf,
475 PLAYLIST_INSERT_LAST, true, true);
476 splash(HZ, ID2P(LANG_QUEUE_LAST));
478 else if (playlist_create(c->currdir, NULL) != -1)
480 start_index = ft_build_playlist(c, c->selected_item);
481 if (global_settings.playlist_shuffle)
483 start_index = playlist_shuffle(seed, start_index);
485 /* when shuffling dir.: play all files
486 even if the file selected by user is
487 not the first one */
488 if (!global_settings.play_selected)
489 start_index = 0;
492 playlist_start(start_index, 0);
493 play = true;
495 break;
497 #if CONFIG_TUNER
498 /* fmr preset file */
499 case FILE_ATTR_FMR:
500 splash(0, ID2P(LANG_WAIT));
502 /* Preset inside the default folder. */
503 if(!strncasecmp(FMPRESET_PATH, buf, strlen(FMPRESET_PATH)))
505 set_file(buf, global_settings.fmr_file, MAX_FILENAME);
506 radio_load_presets(global_settings.fmr_file);
509 * Preset outside default folder, we can choose such only
510 * if we are out of the radio screen, so the check for the
511 * radio status isn't neccessary
513 else
515 radio_load_presets(buf);
517 rc = GO_TO_FM;
519 break;
520 case FILE_ATTR_FMS:
521 splash(0, ID2P(LANG_WAIT));
522 set_file(buf, (char *)global_settings.fms_file, MAX_FILENAME);
523 settings_apply_skins();
524 break;
525 #ifdef HAVE_REMOTE_LCD
526 case FILE_ATTR_RFMS:
527 splash(0, ID2P(LANG_WAIT));
528 set_file(buf, (char *)global_settings.rfms_file, MAX_FILENAME);
529 settings_apply_skins();
530 break;
531 #endif
532 #endif
534 #ifdef HAVE_LCD_BITMAP
535 case FILE_ATTR_SBS:
536 splash(0, ID2P(LANG_WAIT));
537 set_file(buf, (char *)global_settings.sbs_file, MAX_FILENAME);
538 settings_apply_skins();
539 break;
540 #endif
541 #ifdef HAVE_REMOTE_LCD
542 case FILE_ATTR_RSBS:
543 splash(0, ID2P(LANG_WAIT));
544 set_file(buf, (char *)global_settings.rsbs_file, MAX_FILENAME);
545 settings_apply_skins();
546 break;
547 #endif
548 /* wps config file */
549 case FILE_ATTR_WPS:
550 splash(0, ID2P(LANG_WAIT));
551 set_file(buf, (char *)global_settings.wps_file,
552 MAX_FILENAME);
553 settings_apply_skins();
554 break;
556 #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
557 /* remote-wps config file */
558 case FILE_ATTR_RWPS:
559 splash(0, ID2P(LANG_WAIT));
560 set_file(buf, (char *)global_settings.rwps_file,
561 MAX_FILENAME);
562 settings_apply_skins();
563 break;
564 #endif
566 case FILE_ATTR_CFG:
567 splash(0, ID2P(LANG_WAIT));
568 if (!settings_load_config(buf,true))
569 break;
570 splash(HZ, ID2P(LANG_SETTINGS_LOADED));
571 break;
573 case FILE_ATTR_BMARK:
574 splash(0, ID2P(LANG_WAIT));
575 bookmark_load(buf, false);
576 rc = GO_TO_FILEBROWSER;
577 break;
579 case FILE_ATTR_LNG:
580 splash(0, ID2P(LANG_WAIT));
581 if (lang_core_load(buf))
583 splash(HZ, ID2P(LANG_FAILED));
584 break;
586 set_file(buf, (char *)global_settings.lang_file,
587 MAX_FILENAME);
588 talk_init(); /* use voice of same language */
589 viewportmanager_theme_changed(THEME_LANGUAGE);
590 settings_apply_skins();
591 splash(HZ, ID2P(LANG_LANGUAGE_LOADED));
592 break;
594 #ifdef HAVE_LCD_BITMAP
595 case FILE_ATTR_FONT:
596 ft_load_font(buf);
597 break;
599 case FILE_ATTR_KBD:
600 splash(0, ID2P(LANG_WAIT));
601 if (!load_kbd(buf))
602 splash(HZ, ID2P(LANG_KEYBOARD_LOADED));
603 set_file(buf, (char *)global_settings.kbd_file, MAX_FILENAME);
604 break;
605 #endif
607 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
608 /* firmware file */
609 case FILE_ATTR_MOD:
610 splash(0, ID2P(LANG_WAIT));
611 audio_hard_stop();
612 rolo_load(buf);
613 break;
614 #endif
616 /* plugin file */
617 case FILE_ATTR_ROCK:
618 case FILE_ATTR_LUA:
620 char *plugin = buf, *argument = NULL, lua_path[MAX_PATH];
621 int ret;
623 if ((file_attr & FILE_ATTR_MASK) == FILE_ATTR_LUA) {
624 snprintf(lua_path, sizeof(lua_path)-1, "%s/lua.rock", VIEWERS_DIR); /* Use a #define here ? */
625 plugin = lua_path;
626 argument = buf;
629 if (global_settings.party_mode && audio_status()) {
630 splash(HZ, ID2P(LANG_PARTY_MODE));
631 break;
633 ret = plugin_load(plugin, argument);
634 switch (ret)
636 case PLUGIN_GOTO_WPS:
637 play = true;
638 break;
639 case PLUGIN_USB_CONNECTED:
640 if(*c->dirfilter > NUM_FILTER_MODES)
641 /* leave sub-browsers after usb, doing
642 otherwise might be confusing to the user */
643 rc = GO_TO_ROOT;
644 else
645 rc = GO_TO_FILEBROWSER;
646 break;
648 case PLUGIN_ERROR:
649 case PLUGIN_OK:
651 default:
652 break;
654 break;
656 case FILE_ATTR_CUE:
657 display_cuesheet_content(buf);
658 break;
660 default:
662 const char* plugin;
664 if (global_settings.party_mode && audio_status()) {
665 splash(HZ, ID2P(LANG_PARTY_MODE));
666 break;
669 struct entry* file = tree_get_entry_at(c, c->selected_item);
670 plugin = filetype_get_plugin(file);
671 if (plugin)
673 switch (plugin_load(plugin,buf))
675 case PLUGIN_USB_CONNECTED:
676 rc = GO_TO_FILEBROWSER;
677 break;
678 case PLUGIN_GOTO_WPS:
679 rc = GO_TO_WPS;
680 break;
682 case PLUGIN_OK:
683 case PLUGIN_ERROR:
685 default:
686 break;
689 break;
693 if ( play ) {
694 /* the resume_index must always be the index in the
695 shuffled list in case shuffle is enabled */
696 global_status.resume_index = start_index;
697 global_status.resume_offset = 0;
698 status_save();
699 rc = GO_TO_WPS;
701 else {
702 if (*c->dirfilter > NUM_FILTER_MODES &&
703 *c->dirfilter != SHOW_CFG &&
704 *c->dirfilter != SHOW_FONT &&
705 *c->dirfilter != SHOW_PLUGINS)
707 rc = GO_TO_ROOT;
711 return rc;
714 int ft_exit(struct tree_context* c)
716 extern char lastfile[]; /* from tree.c */
717 char buf[MAX_PATH];
718 int rc = 0;
719 bool exit_func = false;
721 int i = strlen(c->currdir);
722 if (i>1) {
723 while (c->currdir[i-1]!='/')
724 i--;
725 strcpy(buf,&c->currdir[i]);
726 if (i==1)
727 c->currdir[i]=0;
728 else
729 c->currdir[i-1]=0;
731 if (*c->dirfilter > NUM_FILTER_MODES && c->dirlevel < 1)
732 exit_func = true;
734 c->dirlevel--;
735 if ( c->dirlevel < MAX_DIR_LEVELS )
736 c->selected_item=c->selected_item_history[c->dirlevel];
737 else
738 c->selected_item=0;
740 /* if undefined position */
741 if (c->selected_item == -1)
742 strcpy(lastfile, buf);
744 else
746 if (*c->dirfilter > NUM_FILTER_MODES && c->dirlevel < 1)
747 exit_func = true;
750 if (exit_func)
751 rc = 3;
753 return rc;