Jonathan Gordon | f331d19 | 2011-11-28 12:41:15 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
Nicolas Pennequin | 357ffb3 | 2008-05-05 10:32:46 +0000 | [diff] [blame] | 10 | * Copyright (C) 2005 by Björn Stenberg |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 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. |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 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> |
Jean-Philippe Bernardy | 00cf0da | 2005-02-15 15:30:19 +0000 | [diff] [blame] | 29 | #include <limits.h> |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 30 | #include "bookmark.h" |
| 31 | #include "tree.h" |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 32 | #include "core_alloc.h" |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 33 | #include "settings.h" |
| 34 | #include "filetypes.h" |
| 35 | #include "talk.h" |
| 36 | #include "playlist.h" |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 37 | #include "lang.h" |
| 38 | #include "language.h" |
| 39 | #include "screens.h" |
| 40 | #include "plugin.h" |
| 41 | #include "rolo.h" |
Kevin Ferrare | e991bee | 2005-11-16 15:12:15 +0000 | [diff] [blame] | 42 | #include "splash.h" |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 43 | #include "cuesheet.h" |
Bertrik Sikken | a5d3029 | 2008-04-28 10:22:05 +0000 | [diff] [blame] | 44 | #include "filetree.h" |
Nils Wallménius | dabcb81 | 2008-05-01 10:13:12 +0000 | [diff] [blame] | 45 | #include "misc.h" |
Thomas Martitz | d13f1a4 | 2009-03-01 17:55:59 +0000 | [diff] [blame] | 46 | #include "strnatcmp.h" |
Frank Dischner | 75c3d0b | 2006-03-29 16:21:42 +0000 | [diff] [blame] | 47 | #ifdef HAVE_LCD_BITMAP |
| 48 | #include "keyboard.h" |
| 49 | #endif |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 50 | |
Jonathan Gordon | 8ff3a65 | 2007-02-18 02:04:47 +0000 | [diff] [blame] | 51 | #if CONFIG_TUNER |
Hristo Kovachev | 009853f | 2006-04-02 12:23:08 +0000 | [diff] [blame] | 52 | #include "radio.h" |
| 53 | #endif |
Thomas Martitz | 3b75c86 | 2009-08-03 15:06:30 +0000 | [diff] [blame] | 54 | #include "wps.h" |
Peter D'Hoye | 93b899d | 2006-05-21 11:00:02 +0000 | [diff] [blame] | 55 | |
Nils Wallménius | 48b52ae | 2008-10-08 16:32:01 +0000 | [diff] [blame] | 56 | static int compare_sort_dir; /* qsort key for sorting directories */ |
| 57 | |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 58 | int ft_build_playlist(struct tree_context* c, int start_index) |
| 59 | { |
| 60 | int i; |
| 61 | int start=start_index; |
| 62 | |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 63 | tree_lock_cache(c); |
| 64 | struct entry *entries = tree_get_entries(c); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 65 | |
| 66 | for(i = 0;i < c->filesindir;i++) |
| 67 | { |
Thomas Martitz | 9809697 | 2011-08-03 09:49:25 +0000 | [diff] [blame] | 68 | if((entries[i].attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 69 | { |
Thomas Martitz | 9809697 | 2011-08-03 09:49:25 +0000 | [diff] [blame] | 70 | if (playlist_add(entries[i].name) < 0) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 71 | break; |
| 72 | } |
| 73 | else |
| 74 | { |
| 75 | /* Adjust the start index when se skip non-MP3 entries */ |
| 76 | if(i < start) |
| 77 | start_index--; |
| 78 | } |
| 79 | } |
| 80 | |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 81 | tree_unlock_cache(c); |
| 82 | |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 83 | return start_index; |
| 84 | } |
| 85 | |
Magnus Holmgren | fabdd38 | 2007-10-30 17:38:21 +0000 | [diff] [blame] | 86 | /* Start playback of a playlist, checking for bookmark autoload, modified |
| 87 | * playlists, etc., as required. Returns false if playback wasn't started, |
| 88 | * or started via bookmark autoload, true otherwise. |
| 89 | * |
| 90 | * Pointers to both the full pathname and the separated parts needed to |
| 91 | * avoid allocating yet another path buffer on the stack (and save some |
| 92 | * code; the caller typically needs to create the full pathname anyway)... |
| 93 | */ |
| 94 | bool ft_play_playlist(char* pathname, char* dirname, char* filename) |
| 95 | { |
Jonathan Gordon | ddc2176 | 2008-08-19 11:55:30 +0000 | [diff] [blame] | 96 | if (global_settings.party_mode && audio_status()) |
Magnus Holmgren | fabdd38 | 2007-10-30 17:38:21 +0000 | [diff] [blame] | 97 | { |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 98 | splash(HZ, ID2P(LANG_PARTY_MODE)); |
Magnus Holmgren | fabdd38 | 2007-10-30 17:38:21 +0000 | [diff] [blame] | 99 | return false; |
| 100 | } |
| 101 | |
| 102 | if (bookmark_autoload(pathname)) |
| 103 | { |
| 104 | return false; |
| 105 | } |
| 106 | |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 107 | splash(0, ID2P(LANG_WAIT)); |
Magnus Holmgren | fabdd38 | 2007-10-30 17:38:21 +0000 | [diff] [blame] | 108 | |
| 109 | /* about to create a new current playlist... |
| 110 | allow user to cancel the operation */ |
Nils Wallménius | dabcb81 | 2008-05-01 10:13:12 +0000 | [diff] [blame] | 111 | if (!warn_on_pl_erase()) |
| 112 | return false; |
Magnus Holmgren | fabdd38 | 2007-10-30 17:38:21 +0000 | [diff] [blame] | 113 | |
| 114 | if (playlist_create(dirname, filename) != -1) |
| 115 | { |
| 116 | if (global_settings.playlist_shuffle) |
| 117 | { |
| 118 | playlist_shuffle(current_tick, -1); |
| 119 | } |
| 120 | |
Michael Sevakis | 31b7122 | 2013-07-14 07:59:39 -0400 | [diff] [blame] | 121 | playlist_start(0, 0, 0); |
Magnus Holmgren | fabdd38 | 2007-10-30 17:38:21 +0000 | [diff] [blame] | 122 | return true; |
| 123 | } |
| 124 | |
| 125 | return false; |
| 126 | } |
| 127 | |
Thomas Martitz | 9809697 | 2011-08-03 09:49:25 +0000 | [diff] [blame] | 128 | /* walk a directory and check all entries if a .talk file exists */ |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 129 | static void check_file_thumbnails(struct tree_context* c) |
| 130 | { |
| 131 | int i; |
Kevin Ferrare | 011a325 | 2007-07-20 17:06:55 +0000 | [diff] [blame] | 132 | struct dirent *entry; |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 133 | struct entry* entries; |
Kevin Ferrare | 011a325 | 2007-07-20 17:06:55 +0000 | [diff] [blame] | 134 | DIR *dir; |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 135 | |
Kevin Ferrare | 011a325 | 2007-07-20 17:06:55 +0000 | [diff] [blame] | 136 | dir = opendir(c->currdir); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 137 | if(!dir) |
| 138 | return; |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 139 | /* mark all files as non talking, except the .talk ones */ |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 140 | tree_lock_cache(c); |
William Wilgus | 3f110da | 2018-12-13 10:39:49 -0600 | [diff] [blame^] | 141 | entries = tree_get_entries(c); |
| 142 | |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 143 | for (i=0; i < c->filesindir; i++) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 144 | { |
Thomas Martitz | 9809697 | 2011-08-03 09:49:25 +0000 | [diff] [blame] | 145 | if (entries[i].attr & ATTR_DIRECTORY) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 146 | continue; /* we're not touching directories */ |
| 147 | |
| 148 | if (strcasecmp(file_thumbnail_ext, |
Thomas Martitz | 9809697 | 2011-08-03 09:49:25 +0000 | [diff] [blame] | 149 | &entries[i].name[strlen(entries[i].name) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 150 | - strlen(file_thumbnail_ext)])) |
| 151 | { /* no .talk file */ |
Thomas Martitz | 9809697 | 2011-08-03 09:49:25 +0000 | [diff] [blame] | 152 | entries[i].attr &= ~FILE_ATTR_THUMBNAIL; /* clear */ |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 153 | } |
| 154 | else |
| 155 | { /* .talk file, we later let them speak themselves */ |
Thomas Martitz | 9809697 | 2011-08-03 09:49:25 +0000 | [diff] [blame] | 156 | entries[i].attr |= FILE_ATTR_THUMBNAIL; /* set */ |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 157 | } |
| 158 | } |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 159 | |
Kevin Ferrare | 011a325 | 2007-07-20 17:06:55 +0000 | [diff] [blame] | 160 | while((entry = readdir(dir)) != 0) /* walk directory */ |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 161 | { |
| 162 | int ext_pos; |
Thomas Martitz | 6eaab4d | 2010-09-01 21:29:34 +0000 | [diff] [blame] | 163 | struct dirinfo info = dir_get_info(dir, entry); |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 164 | ext_pos = strlen((char *)entry->d_name) - strlen(file_thumbnail_ext); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 165 | if (ext_pos <= 0 /* too short to carry ".talk" */ |
Thomas Martitz | 6eaab4d | 2010-09-01 21:29:34 +0000 | [diff] [blame] | 166 | || (info.attribute & ATTR_DIRECTORY) /* no file */ |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 167 | || strcasecmp((char *)&entry->d_name[ext_pos], file_thumbnail_ext)) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 168 | { /* or doesn't end with ".talk", no candidate */ |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 169 | continue; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 170 | } |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 171 | |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 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'; |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 175 | |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 176 | /* search corresponding file in dir cache */ |
| 177 | for (i=0; i < c->filesindir; i++) |
| 178 | { |
Thomas Martitz | 9809697 | 2011-08-03 09:49:25 +0000 | [diff] [blame] | 179 | if (!strcasecmp(entries[i].name, (char *)entry->d_name)) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 180 | { /* match */ |
Thomas Martitz | 9809697 | 2011-08-03 09:49:25 +0000 | [diff] [blame] | 181 | entries[i].attr |= FILE_ATTR_THUMBNAIL; /* set the flag */ |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 182 | break; /* exit search loop, because we found it */ |
| 183 | } |
| 184 | } |
| 185 | } |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 186 | tree_unlock_cache(c); |
Kevin Ferrare | 011a325 | 2007-07-20 17:06:55 +0000 | [diff] [blame] | 187 | closedir(dir); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | /* support function for qsort() */ |
| 191 | static int compare(const void* p1, const void* p2) |
| 192 | { |
| 193 | struct entry* e1 = (struct entry*)p1; |
| 194 | struct entry* e2 = (struct entry*)p2; |
| 195 | int criteria; |
| 196 | |
| 197 | if (e1->attr & ATTR_DIRECTORY && e2->attr & ATTR_DIRECTORY) |
| 198 | { /* two directories */ |
Nils Wallménius | 48b52ae | 2008-10-08 16:32:01 +0000 | [diff] [blame] | 199 | criteria = compare_sort_dir; |
Björn Stenberg | b2d84b1 | 2005-01-17 12:29:27 +0000 | [diff] [blame] | 200 | |
Nils Wallménius | 685f6bb | 2007-03-17 00:55:23 +0000 | [diff] [blame] | 201 | #ifdef HAVE_MULTIVOLUME |
Björn Stenberg | b2d84b1 | 2005-01-17 12:29:27 +0000 | [diff] [blame] | 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) |
Nils Wallménius | 48b52ae | 2008-10-08 16:32:01 +0000 | [diff] [blame] | 205 | criteria = SORT_ALPHA; /* two volumes: sort alphabetically */ |
Björn Stenberg | b2d84b1 | 2005-01-17 12:29:27 +0000 | [diff] [blame] | 206 | else /* only one is a volume: volume first */ |
| 207 | return (e2->attr & ATTR_VOLUME) - (e1->attr & ATTR_VOLUME); |
| 208 | } |
Nils Wallménius | 685f6bb | 2007-03-17 00:55:23 +0000 | [diff] [blame] | 209 | #endif |
| 210 | |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 211 | } |
| 212 | else if (!(e1->attr & ATTR_DIRECTORY) && !(e2->attr & ATTR_DIRECTORY)) |
| 213 | { /* two files */ |
| 214 | criteria = global_settings.sort_file; |
| 215 | } |
| 216 | else /* dir and file, dir goes first */ |
Nils Wallménius | 48b52ae | 2008-10-08 16:32:01 +0000 | [diff] [blame] | 217 | return (e2->attr & ATTR_DIRECTORY) - (e1->attr & ATTR_DIRECTORY); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 218 | |
| 219 | switch(criteria) |
| 220 | { |
Nils Wallménius | 48b52ae | 2008-10-08 16:32:01 +0000 | [diff] [blame] | 221 | case SORT_TYPE: |
| 222 | case SORT_TYPE_REVERSED: |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 223 | { |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 224 | int t1 = e1->attr & FILE_ATTR_MASK; |
| 225 | int t2 = e2->attr & FILE_ATTR_MASK; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 226 | |
| 227 | if (!t1) /* unknown type */ |
Jean-Philippe Bernardy | 8758713 | 2005-02-12 12:29:41 +0000 | [diff] [blame] | 228 | t1 = INT_MAX; /* gets a high number, to sort after known */ |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 229 | if (!t2) /* unknown type */ |
Jean-Philippe Bernardy | 8758713 | 2005-02-12 12:29:41 +0000 | [diff] [blame] | 230 | t2 = INT_MAX; /* gets a high number, to sort after known */ |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 231 | |
Nils Wallménius | 48b52ae | 2008-10-08 16:32:01 +0000 | [diff] [blame] | 232 | if (t1 != t2) /* if different */ |
| 233 | return (t1 - t2) * (criteria == SORT_TYPE_REVERSED ? -1 : 1); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 234 | /* else fall through to alphabetical sorting */ |
| 235 | } |
Nils Wallménius | 48b52ae | 2008-10-08 16:32:01 +0000 | [diff] [blame] | 236 | |
| 237 | case SORT_DATE: |
| 238 | case SORT_DATE_REVERSED: |
| 239 | /* Ignore SORT_TYPE */ |
| 240 | if (criteria == SORT_DATE || criteria == SORT_DATE_REVERSED) |
| 241 | { |
| 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 */ |
| 246 | } |
| 247 | |
| 248 | case SORT_ALPHA: |
| 249 | case SORT_ALPHA_REVERSED: |
Thomas Martitz | d13f1a4 | 2009-03-01 17:55:59 +0000 | [diff] [blame] | 250 | { |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 251 | if (global_settings.sort_case) |
Thomas Martitz | d13f1a4 | 2009-03-01 17:55:59 +0000 | [diff] [blame] | 252 | { |
| 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); |
| 259 | } |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 260 | else |
Thomas Martitz | d13f1a4 | 2009-03-01 17:55:59 +0000 | [diff] [blame] | 261 | { |
| 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); |
| 268 | } |
| 269 | } |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 270 | |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 271 | } |
| 272 | return 0; /* never reached */ |
| 273 | } |
| 274 | |
Thomas Martitz | 9809697 | 2011-08-03 09:49:25 +0000 | [diff] [blame] | 275 | /* load and sort directory into the tree's cache. returns NULL on failure. */ |
Björn Stenberg | cdd79a3 | 2005-01-18 22:50:47 +0000 | [diff] [blame] | 276 | int ft_load(struct tree_context* c, const char* tempdir) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 277 | { |
Magnus Holmgren | c2ff646 | 2011-05-04 18:33:12 +0000 | [diff] [blame] | 278 | int files_in_dir = 0; |
Björn Stenberg | a50cc0b | 2005-01-17 12:56:00 +0000 | [diff] [blame] | 279 | int name_buffer_used = 0; |
Magnus Holmgren | c2ff646 | 2011-05-04 18:33:12 +0000 | [diff] [blame] | 280 | struct dirent *entry; |
Teruaki Kawashima | 08af5d8 | 2010-12-14 13:37:58 +0000 | [diff] [blame] | 281 | bool (*callback_show_item)(char *, int, struct tree_context *) = NULL; |
Kevin Ferrare | 011a325 | 2007-07-20 17:06:55 +0000 | [diff] [blame] | 282 | DIR *dir; |
Björn Stenberg | cdd79a3 | 2005-01-18 22:50:47 +0000 | [diff] [blame] | 283 | |
| 284 | if (tempdir) |
Kevin Ferrare | 011a325 | 2007-07-20 17:06:55 +0000 | [diff] [blame] | 285 | dir = opendir(tempdir); |
Björn Stenberg | cdd79a3 | 2005-01-18 22:50:47 +0000 | [diff] [blame] | 286 | else |
Teruaki Kawashima | 08af5d8 | 2010-12-14 13:37:58 +0000 | [diff] [blame] | 287 | { |
Kevin Ferrare | 011a325 | 2007-07-20 17:06:55 +0000 | [diff] [blame] | 288 | dir = opendir(c->currdir); |
Teruaki Kawashima | 08af5d8 | 2010-12-14 13:37:58 +0000 | [diff] [blame] | 289 | callback_show_item = c->browse? c->browse->callback_show_item: NULL; |
| 290 | } |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 291 | if(!dir) |
| 292 | return -1; /* not a directory */ |
| 293 | |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 294 | c->dirsindir = 0; |
Björn Stenberg | 84c7d880 | 2005-01-18 22:45:00 +0000 | [diff] [blame] | 295 | c->dirfull = false; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 296 | |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 297 | tree_lock_cache(c); |
Magnus Holmgren | c2ff646 | 2011-05-04 18:33:12 +0000 | [diff] [blame] | 298 | while ((entry = readdir(dir))) { |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 299 | int len; |
Thomas Martitz | 6eaab4d | 2010-09-01 21:29:34 +0000 | [diff] [blame] | 300 | struct dirinfo info; |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 301 | struct entry* dptr = tree_get_entry_at(c, files_in_dir); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 302 | if (!entry) |
| 303 | break; |
| 304 | |
Thomas Martitz | 6eaab4d | 2010-09-01 21:29:34 +0000 | [diff] [blame] | 305 | info = dir_get_info(dir, entry); |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 306 | len = strlen((char *)entry->d_name); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 307 | |
| 308 | /* skip directories . and .. */ |
Thomas Martitz | 6eaab4d | 2010-09-01 21:29:34 +0000 | [diff] [blame] | 309 | if ((info.attribute & ATTR_DIRECTORY) && |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 310 | (((len == 1) && (!strncmp((char *)entry->d_name, ".", 1))) || |
| 311 | ((len == 2) && (!strncmp((char *)entry->d_name, "..", 2))))) { |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 312 | continue; |
| 313 | } |
| 314 | |
| 315 | /* Skip FAT volume ID */ |
Thomas Martitz | 6eaab4d | 2010-09-01 21:29:34 +0000 | [diff] [blame] | 316 | if (info.attribute & ATTR_VOLUME_ID) { |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 317 | continue; |
| 318 | } |
| 319 | |
| 320 | /* filter out dotfiles and hidden files */ |
| 321 | if (*c->dirfilter != SHOW_ALL && |
| 322 | ((entry->d_name[0]=='.') || |
Thomas Martitz | 6eaab4d | 2010-09-01 21:29:34 +0000 | [diff] [blame] | 323 | (info.attribute & ATTR_HIDDEN))) { |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 324 | continue; |
| 325 | } |
| 326 | |
Thomas Martitz | 6eaab4d | 2010-09-01 21:29:34 +0000 | [diff] [blame] | 327 | dptr->attr = info.attribute; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 328 | |
| 329 | /* check for known file types */ |
Henrik Backe | b2473d5 | 2005-09-02 15:05:35 +0000 | [diff] [blame] | 330 | if ( !(dptr->attr & ATTR_DIRECTORY) ) |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 331 | dptr->attr |= filetype_get_attr((char *)entry->d_name); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 332 | |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 333 | /* filter out non-visible files */ |
Jonas Häggqvist | 280d9cc | 2005-08-17 17:53:54 +0000 | [diff] [blame] | 334 | if ((!(dptr->attr & ATTR_DIRECTORY) && ( |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 335 | (*c->dirfilter == SHOW_PLAYLIST && |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 336 | (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) || |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 337 | ((*c->dirfilter == SHOW_MUSIC && |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 338 | (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) && |
| 339 | (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) || |
Jonas Häggqvist | 280d9cc | 2005-08-17 17:53:54 +0000 | [diff] [blame] | 340 | (*c->dirfilter == SHOW_SUPPORTED && !filetype_supported(dptr->attr)))) || |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 341 | (*c->dirfilter == SHOW_WPS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_WPS) || |
Thomas Martitz | de7f241 | 2009-10-19 16:08:43 +0000 | [diff] [blame] | 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) || |
Jonathan Gordon | 1bd072c | 2010-05-12 10:38:00 +0000 | [diff] [blame] | 345 | #if CONFIG_TUNER |
| 346 | (*c->dirfilter == SHOW_FMS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FMS) || |
| 347 | #endif |
Thomas Martitz | de7f241 | 2009-10-19 16:08:43 +0000 | [diff] [blame] | 348 | #endif |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 349 | #ifdef HAVE_REMOTE_LCD |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 350 | (*c->dirfilter == SHOW_RWPS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RWPS) || |
Thomas Martitz | de7f241 | 2009-10-19 16:08:43 +0000 | [diff] [blame] | 351 | (*c->dirfilter == SHOW_RSBS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RSBS) || |
Jonathan Gordon | 1bd072c | 2010-05-12 10:38:00 +0000 | [diff] [blame] | 352 | #if CONFIG_TUNER |
| 353 | (*c->dirfilter == SHOW_RFMS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RFMS) || |
| 354 | #endif |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 355 | #endif |
Jonathan Gordon | 8ff3a65 | 2007-02-18 02:04:47 +0000 | [diff] [blame] | 356 | #if CONFIG_TUNER |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 357 | (*c->dirfilter == SHOW_FMR && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FMR) || |
Hristo Kovachev | 009853f | 2006-04-02 12:23:08 +0000 | [diff] [blame] | 358 | #endif |
Teruaki Kawashima | e6b4d8f | 2010-12-15 12:47:30 +0000 | [diff] [blame] | 359 | (*c->dirfilter == SHOW_M3U && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) || |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 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) || |
Maurus Cuelenaere | d789e41 | 2009-10-28 23:31:42 +0000 | [diff] [blame] | 363 | (*c->dirfilter == SHOW_PLUGINS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_ROCK && |
Teruaki Kawashima | 08af5d8 | 2010-12-14 13:37:58 +0000 | [diff] [blame] | 364 | (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_LUA) || |
| 365 | (callback_show_item && !callback_show_item(entry->d_name, dptr->attr, c))) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 366 | { |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 367 | continue; |
| 368 | } |
| 369 | |
Thomas Martitz | 9809697 | 2011-08-03 09:49:25 +0000 | [diff] [blame] | 370 | if ((len > c->cache.name_buffer_size - name_buffer_used - 1) || |
| 371 | (files_in_dir >= c->cache.max_entries)) { |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 372 | /* Tell the world that we ran out of buffer space */ |
Björn Stenberg | 84c7d880 | 2005-01-18 22:45:00 +0000 | [diff] [blame] | 373 | c->dirfull = true; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 374 | break; |
| 375 | } |
Magnus Holmgren | c2ff646 | 2011-05-04 18:33:12 +0000 | [diff] [blame] | 376 | |
| 377 | ++files_in_dir; |
| 378 | |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 379 | dptr->name = core_get_data(c->cache.name_buffer_handle)+name_buffer_used; |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 380 | dptr->time_write = info.mtime; |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 381 | strcpy(dptr->name, (char *)entry->d_name); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 382 | name_buffer_used += len + 1; |
| 383 | |
| 384 | if (dptr->attr & ATTR_DIRECTORY) /* count the remaining dirs */ |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 385 | c->dirsindir++; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 386 | } |
Magnus Holmgren | c2ff646 | 2011-05-04 18:33:12 +0000 | [diff] [blame] | 387 | c->filesindir = files_in_dir; |
| 388 | c->dirlength = files_in_dir; |
Kevin Ferrare | 011a325 | 2007-07-20 17:06:55 +0000 | [diff] [blame] | 389 | closedir(dir); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 390 | |
Nils Wallménius | 48b52ae | 2008-10-08 16:32:01 +0000 | [diff] [blame] | 391 | compare_sort_dir = c->sort_dir; |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 392 | qsort(tree_get_entries(c), files_in_dir, sizeof(struct entry), compare); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 393 | |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 394 | /* If thumbnail talking is enabled, make an extra run to mark files with |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 395 | associated thumbnails, so we don't do unsuccessful spinups later. */ |
Steve Bavin | a1f0a83 | 2007-06-07 11:29:45 +0000 | [diff] [blame] | 396 | if (global_settings.talk_file_clip) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 397 | check_file_thumbnails(c); /* map .talk to ours */ |
| 398 | |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 399 | tree_unlock_cache(c); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 400 | return 0; |
| 401 | } |
Jonathan Gordon | 1c2aa35 | 2010-02-14 06:26:16 +0000 | [diff] [blame] | 402 | #ifdef HAVE_LCD_BITMAP |
| 403 | static void ft_load_font(char *file) |
| 404 | { |
Jonathan Gordon | aa0f4a4 | 2011-09-24 13:19:34 +0000 | [diff] [blame] | 405 | int current_font_id; |
| 406 | enum screen_type screen = SCREEN_MAIN; |
Jonathan Gordon | 1c2aa35 | 2010-02-14 06:26:16 +0000 | [diff] [blame] | 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)) |
| 411 | { |
Jonathan Gordon | aa0f4a4 | 2011-09-24 13:19:34 +0000 | [diff] [blame] | 412 | case 0: /* main lcd */ |
| 413 | screen = SCREEN_MAIN; |
Jonathan Gordon | 1c2aa35 | 2010-02-14 06:26:16 +0000 | [diff] [blame] | 414 | set_file(file, (char *)global_settings.font_file, MAX_FILENAME); |
| 415 | break; |
| 416 | case 1: /* remote */ |
Jonathan Gordon | aa0f4a4 | 2011-09-24 13:19:34 +0000 | [diff] [blame] | 417 | screen = SCREEN_REMOTE; |
Jonathan Gordon | 1c2aa35 | 2010-02-14 06:26:16 +0000 | [diff] [blame] | 418 | set_file(file, (char *)global_settings.remote_font_file, MAX_FILENAME); |
| 419 | break; |
| 420 | } |
| 421 | #else |
Jonathan Gordon | 1c2aa35 | 2010-02-14 06:26:16 +0000 | [diff] [blame] | 422 | set_file(file, (char *)global_settings.font_file, MAX_FILENAME); |
| 423 | #endif |
Jonathan Gordon | aa0f4a4 | 2011-09-24 13:19:34 +0000 | [diff] [blame] | 424 | splash(0, ID2P(LANG_WAIT)); |
Jonathan Gordon | f19f3ef | 2011-11-08 10:09:33 +0000 | [diff] [blame] | 425 | current_font_id = screens[screen].getuifont(); |
Jonathan Gordon | aa0f4a4 | 2011-09-24 13:19:34 +0000 | [diff] [blame] | 426 | if (current_font_id >= 0) |
| 427 | font_unload(current_font_id); |
Fred Bauer | bccee89 | 2011-11-20 18:03:39 +0000 | [diff] [blame] | 428 | screens[screen].setuifont( |
| 429 | font_load_ex(file,0,global_settings.glyphs_to_cache)); |
Jonathan Gordon | aa0f4a4 | 2011-09-24 13:19:34 +0000 | [diff] [blame] | 430 | viewportmanager_theme_changed(THEME_UI_VIEWPORT); |
Jonathan Gordon | 1c2aa35 | 2010-02-14 06:26:16 +0000 | [diff] [blame] | 431 | } |
| 432 | #endif |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 433 | |
| 434 | int ft_enter(struct tree_context* c) |
| 435 | { |
Jonathan Gordon | 43c85a4 | 2010-08-16 13:16:29 +0000 | [diff] [blame] | 436 | int rc = GO_TO_PREVIOUS; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 437 | char buf[MAX_PATH]; |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 438 | struct entry* file = tree_get_entry_at(c, c->selected_item); |
| 439 | int file_attr = file->attr; |
William Wilgus | 5e5ddce | 2018-07-25 19:28:25 +0200 | [diff] [blame] | 440 | int len; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 441 | |
| 442 | if (c->currdir[1]) |
William Wilgus | 5e5ddce | 2018-07-25 19:28:25 +0200 | [diff] [blame] | 443 | { |
| 444 | len = snprintf(buf,sizeof(buf),"%s/%s",c->currdir, file->name); |
| 445 | if ((unsigned) len > sizeof(buf)) |
| 446 | splash(HZ, ID2P(LANG_PLAYLIST_ACCESS_ERROR)); |
| 447 | } |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 448 | else |
| 449 | snprintf(buf,sizeof(buf),"/%s",file->name); |
| 450 | |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 451 | if (file_attr & ATTR_DIRECTORY) { |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 452 | memcpy(c->currdir, buf, sizeof(c->currdir)); |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 453 | if ( c->dirlevel < MAX_DIR_LEVELS ) |
| 454 | c->selected_item_history[c->dirlevel] = c->selected_item; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 455 | c->dirlevel++; |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 456 | c->selected_item=0; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 457 | } |
| 458 | else { |
| 459 | int seed = current_tick; |
| 460 | bool play = false; |
| 461 | int start_index=0; |
| 462 | |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 463 | switch ( file_attr & FILE_ATTR_MASK ) { |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 464 | case FILE_ATTR_M3U: |
Jonathan Gordon | f331d19 | 2011-11-28 12:41:15 +0000 | [diff] [blame] | 465 | play = ft_play_playlist(buf, c->currdir, file->name); |
| 466 | |
| 467 | if (play) |
| 468 | { |
| 469 | start_index = 0; |
| 470 | } |
| 471 | |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 472 | break; |
| 473 | |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 474 | case FILE_ATTR_AUDIO: |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 475 | if (bookmark_autoload(c->currdir)) |
| 476 | break; |
| 477 | |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 478 | splash(0, ID2P(LANG_WAIT)); |
Zakk Roberts | ddb36b2 | 2006-04-15 06:23:34 +0000 | [diff] [blame] | 479 | |
Hardeep Sidhu | 941de85 | 2006-02-05 19:35:03 +0000 | [diff] [blame] | 480 | /* about to create a new current playlist... |
| 481 | allow user to cancel the operation */ |
Nils Wallménius | dabcb81 | 2008-05-01 10:13:12 +0000 | [diff] [blame] | 482 | if (!warn_on_pl_erase()) |
| 483 | break; |
Hardeep Sidhu | 941de85 | 2006-02-05 19:35:03 +0000 | [diff] [blame] | 484 | |
Jonathan Gordon | ddc2176 | 2008-08-19 11:55:30 +0000 | [diff] [blame] | 485 | if (global_settings.party_mode && audio_status()) |
Miika Pekkarinen | 887cfeb | 2006-08-10 09:50:45 +0000 | [diff] [blame] | 486 | { |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 487 | playlist_insert_track(NULL, buf, |
Miika Pekkarinen | 887cfeb | 2006-08-10 09:50:45 +0000 | [diff] [blame] | 488 | PLAYLIST_INSERT_LAST, true, true); |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 489 | splash(HZ, ID2P(LANG_QUEUE_LAST)); |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 490 | } |
| 491 | else if (playlist_create(c->currdir, NULL) != -1) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 492 | { |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 493 | start_index = ft_build_playlist(c, c->selected_item); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 494 | if (global_settings.playlist_shuffle) |
| 495 | { |
| 496 | start_index = playlist_shuffle(seed, start_index); |
| 497 | |
| 498 | /* when shuffling dir.: play all files |
| 499 | even if the file selected by user is |
| 500 | not the first one */ |
| 501 | if (!global_settings.play_selected) |
| 502 | start_index = 0; |
| 503 | } |
| 504 | |
Michael Sevakis | 31b7122 | 2013-07-14 07:59:39 -0400 | [diff] [blame] | 505 | playlist_start(start_index, 0, 0); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 506 | play = true; |
| 507 | } |
| 508 | break; |
| 509 | |
Jonathan Gordon | 8ff3a65 | 2007-02-18 02:04:47 +0000 | [diff] [blame] | 510 | #if CONFIG_TUNER |
Hristo Kovachev | 009853f | 2006-04-02 12:23:08 +0000 | [diff] [blame] | 511 | /* fmr preset file */ |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 512 | case FILE_ATTR_FMR: |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 513 | splash(0, ID2P(LANG_WAIT)); |
Zakk Roberts | ddb36b2 | 2006-04-15 06:23:34 +0000 | [diff] [blame] | 514 | |
Hristo Kovachev | 009853f | 2006-04-02 12:23:08 +0000 | [diff] [blame] | 515 | /* Preset inside the default folder. */ |
| 516 | if(!strncasecmp(FMPRESET_PATH, buf, strlen(FMPRESET_PATH))) |
| 517 | { |
| 518 | set_file(buf, global_settings.fmr_file, MAX_FILENAME); |
| 519 | radio_load_presets(global_settings.fmr_file); |
Hristo Kovachev | 009853f | 2006-04-02 12:23:08 +0000 | [diff] [blame] | 520 | } |
Zakk Roberts | ddb36b2 | 2006-04-15 06:23:34 +0000 | [diff] [blame] | 521 | /* |
Hristo Kovachev | 009853f | 2006-04-02 12:23:08 +0000 | [diff] [blame] | 522 | * Preset outside default folder, we can choose such only |
Zakk Roberts | ddb36b2 | 2006-04-15 06:23:34 +0000 | [diff] [blame] | 523 | * if we are out of the radio screen, so the check for the |
| 524 | * radio status isn't neccessary |
Hristo Kovachev | 009853f | 2006-04-02 12:23:08 +0000 | [diff] [blame] | 525 | */ |
| 526 | else |
| 527 | { |
| 528 | radio_load_presets(buf); |
Hristo Kovachev | 009853f | 2006-04-02 12:23:08 +0000 | [diff] [blame] | 529 | } |
Jonathan Gordon | 43c85a4 | 2010-08-16 13:16:29 +0000 | [diff] [blame] | 530 | rc = GO_TO_FM; |
Zakk Roberts | ddb36b2 | 2006-04-15 06:23:34 +0000 | [diff] [blame] | 531 | |
Hristo Kovachev | 009853f | 2006-04-02 12:23:08 +0000 | [diff] [blame] | 532 | break; |
Jonathan Gordon | 1bd072c | 2010-05-12 10:38:00 +0000 | [diff] [blame] | 533 | case FILE_ATTR_FMS: |
| 534 | splash(0, ID2P(LANG_WAIT)); |
| 535 | set_file(buf, (char *)global_settings.fms_file, MAX_FILENAME); |
| 536 | settings_apply_skins(); |
| 537 | break; |
| 538 | #ifdef HAVE_REMOTE_LCD |
| 539 | case FILE_ATTR_RFMS: |
| 540 | splash(0, ID2P(LANG_WAIT)); |
| 541 | set_file(buf, (char *)global_settings.rfms_file, MAX_FILENAME); |
| 542 | settings_apply_skins(); |
| 543 | break; |
| 544 | #endif |
Hristo Kovachev | 009853f | 2006-04-02 12:23:08 +0000 | [diff] [blame] | 545 | #endif |
| 546 | |
Thomas Martitz | 1016ee4 | 2009-10-19 15:28:15 +0000 | [diff] [blame] | 547 | #ifdef HAVE_LCD_BITMAP |
| 548 | case FILE_ATTR_SBS: |
| 549 | splash(0, ID2P(LANG_WAIT)); |
Jonathan Gordon | a9b5f4d | 2010-03-06 00:29:46 +0000 | [diff] [blame] | 550 | set_file(buf, (char *)global_settings.sbs_file, MAX_FILENAME); |
Thomas Martitz | 1016ee4 | 2009-10-19 15:28:15 +0000 | [diff] [blame] | 551 | settings_apply_skins(); |
Thomas Martitz | 1016ee4 | 2009-10-19 15:28:15 +0000 | [diff] [blame] | 552 | break; |
| 553 | #endif |
| 554 | #ifdef HAVE_REMOTE_LCD |
| 555 | case FILE_ATTR_RSBS: |
| 556 | splash(0, ID2P(LANG_WAIT)); |
Jonathan Gordon | a9b5f4d | 2010-03-06 00:29:46 +0000 | [diff] [blame] | 557 | set_file(buf, (char *)global_settings.rsbs_file, MAX_FILENAME); |
Thomas Martitz | 1016ee4 | 2009-10-19 15:28:15 +0000 | [diff] [blame] | 558 | settings_apply_skins(); |
Thomas Martitz | 1016ee4 | 2009-10-19 15:28:15 +0000 | [diff] [blame] | 559 | break; |
| 560 | #endif |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 561 | /* wps config file */ |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 562 | case FILE_ATTR_WPS: |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 563 | splash(0, ID2P(LANG_WAIT)); |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 564 | set_file(buf, (char *)global_settings.wps_file, |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 565 | MAX_FILENAME); |
Thomas Martitz | c426628 | 2009-08-16 20:12:17 +0000 | [diff] [blame] | 566 | settings_apply_skins(); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 567 | break; |
| 568 | |
Magnus Holmgren | f9fa33f | 2005-12-04 12:11:08 +0000 | [diff] [blame] | 569 | #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 570 | /* remote-wps config file */ |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 571 | case FILE_ATTR_RWPS: |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 572 | splash(0, ID2P(LANG_WAIT)); |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 573 | set_file(buf, (char *)global_settings.rwps_file, |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 574 | MAX_FILENAME); |
Thomas Martitz | c426628 | 2009-08-16 20:12:17 +0000 | [diff] [blame] | 575 | settings_apply_skins(); |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 576 | break; |
| 577 | #endif |
| 578 | |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 579 | case FILE_ATTR_CFG: |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 580 | splash(0, ID2P(LANG_WAIT)); |
Jonathan Gordon | b2e5090 | 2007-01-23 13:40:44 +0000 | [diff] [blame] | 581 | if (!settings_load_config(buf,true)) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 582 | break; |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 583 | splash(HZ, ID2P(LANG_SETTINGS_LOADED)); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 584 | break; |
| 585 | |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 586 | case FILE_ATTR_BMARK: |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 587 | splash(0, ID2P(LANG_WAIT)); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 588 | bookmark_load(buf, false); |
Jonathan Gordon | 43c85a4 | 2010-08-16 13:16:29 +0000 | [diff] [blame] | 589 | rc = GO_TO_FILEBROWSER; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 590 | break; |
| 591 | |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 592 | case FILE_ATTR_LNG: |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 593 | splash(0, ID2P(LANG_WAIT)); |
Tomer Shalev | bb5078c | 2009-10-19 15:50:06 +0000 | [diff] [blame] | 594 | if (lang_core_load(buf)) |
| 595 | { |
Tomer Shalev | 9351d41 | 2009-10-19 16:01:05 +0000 | [diff] [blame] | 596 | splash(HZ, ID2P(LANG_FAILED)); |
Tomer Shalev | bb5078c | 2009-10-19 15:50:06 +0000 | [diff] [blame] | 597 | break; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 598 | } |
Tomer Shalev | bb5078c | 2009-10-19 15:50:06 +0000 | [diff] [blame] | 599 | set_file(buf, (char *)global_settings.lang_file, |
| 600 | MAX_FILENAME); |
| 601 | talk_init(); /* use voice of same language */ |
| 602 | viewportmanager_theme_changed(THEME_LANGUAGE); |
Jonathan Gordon | 91e6b06 | 2010-01-07 07:34:15 +0000 | [diff] [blame] | 603 | settings_apply_skins(); |
Tomer Shalev | bb5078c | 2009-10-19 15:50:06 +0000 | [diff] [blame] | 604 | splash(HZ, ID2P(LANG_LANGUAGE_LOADED)); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 605 | break; |
| 606 | |
| 607 | #ifdef HAVE_LCD_BITMAP |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 608 | case FILE_ATTR_FONT: |
Jonathan Gordon | 1c2aa35 | 2010-02-14 06:26:16 +0000 | [diff] [blame] | 609 | ft_load_font(buf); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 610 | break; |
Frank Dischner | 75c3d0b | 2006-03-29 16:21:42 +0000 | [diff] [blame] | 611 | |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 612 | case FILE_ATTR_KBD: |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 613 | splash(0, ID2P(LANG_WAIT)); |
Frank Dischner | 75c3d0b | 2006-03-29 16:21:42 +0000 | [diff] [blame] | 614 | if (!load_kbd(buf)) |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 615 | splash(HZ, ID2P(LANG_KEYBOARD_LOADED)); |
Frank Dischner | 75c3d0b | 2006-03-29 16:21:42 +0000 | [diff] [blame] | 616 | set_file(buf, (char *)global_settings.kbd_file, MAX_FILENAME); |
| 617 | break; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 618 | #endif |
| 619 | |
Thomas Martitz | 35e8b14 | 2010-06-21 16:53:00 +0000 | [diff] [blame] | 620 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 621 | /* firmware file */ |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 622 | case FILE_ATTR_MOD: |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 623 | splash(0, ID2P(LANG_WAIT)); |
Thomas Martitz | d1322b7 | 2011-08-14 15:13:00 +0000 | [diff] [blame] | 624 | audio_hard_stop(); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 625 | rolo_load(buf); |
| 626 | break; |
| 627 | #endif |
| 628 | |
| 629 | /* plugin file */ |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 630 | case FILE_ATTR_ROCK: |
Maurus Cuelenaere | d789e41 | 2009-10-28 23:31:42 +0000 | [diff] [blame] | 631 | case FILE_ATTR_LUA: |
Thomas Martitz | df6f955 | 2009-07-05 22:12:42 +0000 | [diff] [blame] | 632 | { |
Thomas Martitz | 9c0b247 | 2010-08-01 16:15:27 +0000 | [diff] [blame] | 633 | char *plugin = buf, *argument = NULL, lua_path[MAX_PATH]; |
Thomas Martitz | df6f955 | 2009-07-05 22:12:42 +0000 | [diff] [blame] | 634 | int ret; |
Maurus Cuelenaere | d789e41 | 2009-10-28 23:31:42 +0000 | [diff] [blame] | 635 | |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 636 | if ((file_attr & FILE_ATTR_MASK) == FILE_ATTR_LUA) { |
Thomas Martitz | 9c0b247 | 2010-08-01 16:15:27 +0000 | [diff] [blame] | 637 | snprintf(lua_path, sizeof(lua_path)-1, "%s/lua.rock", VIEWERS_DIR); /* Use a #define here ? */ |
| 638 | plugin = lua_path; |
Maurus Cuelenaere | d789e41 | 2009-10-28 23:31:42 +0000 | [diff] [blame] | 639 | argument = buf; |
| 640 | } |
| 641 | |
Jonathan Gordon | ddc2176 | 2008-08-19 11:55:30 +0000 | [diff] [blame] | 642 | if (global_settings.party_mode && audio_status()) { |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 643 | splash(HZ, ID2P(LANG_PARTY_MODE)); |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 644 | break; |
| 645 | } |
Maurus Cuelenaere | d789e41 | 2009-10-28 23:31:42 +0000 | [diff] [blame] | 646 | ret = plugin_load(plugin, argument); |
Thomas Martitz | df6f955 | 2009-07-05 22:12:42 +0000 | [diff] [blame] | 647 | switch (ret) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 648 | { |
Thomas Martitz | df6f955 | 2009-07-05 22:12:42 +0000 | [diff] [blame] | 649 | case PLUGIN_GOTO_WPS: |
| 650 | play = true; |
| 651 | break; |
| 652 | case PLUGIN_USB_CONNECTED: |
| 653 | if(*c->dirfilter > NUM_FILTER_MODES) |
| 654 | /* leave sub-browsers after usb, doing |
| 655 | otherwise might be confusing to the user */ |
Jonathan Gordon | 43c85a4 | 2010-08-16 13:16:29 +0000 | [diff] [blame] | 656 | rc = GO_TO_ROOT; |
Thomas Martitz | df6f955 | 2009-07-05 22:12:42 +0000 | [diff] [blame] | 657 | else |
Jonathan Gordon | 43c85a4 | 2010-08-16 13:16:29 +0000 | [diff] [blame] | 658 | rc = GO_TO_FILEBROWSER; |
Thomas Martitz | df6f955 | 2009-07-05 22:12:42 +0000 | [diff] [blame] | 659 | break; |
| 660 | /* |
| 661 | case PLUGIN_ERROR: |
| 662 | case PLUGIN_OK: |
| 663 | */ |
| 664 | default: |
| 665 | break; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 666 | } |
| 667 | break; |
Thomas Martitz | df6f955 | 2009-07-05 22:12:42 +0000 | [diff] [blame] | 668 | } |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 669 | case FILE_ATTR_CUE: |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 670 | display_cuesheet_content(buf); |
| 671 | break; |
| 672 | |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 673 | default: |
| 674 | { |
Steve Bavin | ad95df2 | 2008-05-12 17:52:50 +0000 | [diff] [blame] | 675 | const char* plugin; |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 676 | |
Jonathan Gordon | ddc2176 | 2008-08-19 11:55:30 +0000 | [diff] [blame] | 677 | if (global_settings.party_mode && audio_status()) { |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 678 | splash(HZ, ID2P(LANG_PARTY_MODE)); |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 679 | break; |
| 680 | } |
Zakk Roberts | ddb36b2 | 2006-04-15 06:23:34 +0000 | [diff] [blame] | 681 | |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 682 | struct entry* file = tree_get_entry_at(c, c->selected_item); |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 683 | plugin = filetype_get_plugin(file); |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 684 | if (plugin) |
| 685 | { |
Thomas Martitz | df6f955 | 2009-07-05 22:12:42 +0000 | [diff] [blame] | 686 | switch (plugin_load(plugin,buf)) |
| 687 | { |
| 688 | case PLUGIN_USB_CONNECTED: |
Jonathan Gordon | 43c85a4 | 2010-08-16 13:16:29 +0000 | [diff] [blame] | 689 | rc = GO_TO_FILEBROWSER; |
Thomas Martitz | df6f955 | 2009-07-05 22:12:42 +0000 | [diff] [blame] | 690 | break; |
| 691 | case PLUGIN_GOTO_WPS: |
Jonathan Gordon | 43c85a4 | 2010-08-16 13:16:29 +0000 | [diff] [blame] | 692 | rc = GO_TO_WPS; |
Thomas Martitz | df6f955 | 2009-07-05 22:12:42 +0000 | [diff] [blame] | 693 | break; |
| 694 | /* |
| 695 | case PLUGIN_OK: |
| 696 | case PLUGIN_ERROR: |
| 697 | */ |
| 698 | default: |
| 699 | break; |
| 700 | } |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 701 | } |
| 702 | break; |
| 703 | } |
| 704 | } |
| 705 | |
| 706 | if ( play ) { |
Christi Scarborough | 9e8918b | 2005-06-29 12:23:09 +0000 | [diff] [blame] | 707 | /* the resume_index must always be the index in the |
| 708 | shuffled list in case shuffle is enabled */ |
Jonathan Gordon | 228d62d | 2007-01-24 02:19:22 +0000 | [diff] [blame] | 709 | global_status.resume_index = start_index; |
Richard Quirk | 212e780 | 2012-12-09 21:04:17 +0100 | [diff] [blame] | 710 | global_status.resume_crc32 = |
| 711 | playlist_get_filename_crc32(NULL, start_index); |
Michael Sevakis | 31b7122 | 2013-07-14 07:59:39 -0400 | [diff] [blame] | 712 | global_status.resume_elapsed = 0; |
Jonathan Gordon | 228d62d | 2007-01-24 02:19:22 +0000 | [diff] [blame] | 713 | global_status.resume_offset = 0; |
| 714 | status_save(); |
Jonathan Gordon | 43c85a4 | 2010-08-16 13:16:29 +0000 | [diff] [blame] | 715 | rc = GO_TO_WPS; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 716 | } |
| 717 | else { |
| 718 | if (*c->dirfilter > NUM_FILTER_MODES && |
Thomas Martitz | deb6b81 | 2009-05-11 22:50:48 +0000 | [diff] [blame] | 719 | *c->dirfilter != SHOW_CFG && |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 720 | *c->dirfilter != SHOW_FONT && |
| 721 | *c->dirfilter != SHOW_PLUGINS) |
| 722 | { |
Jonathan Gordon | 43c85a4 | 2010-08-16 13:16:29 +0000 | [diff] [blame] | 723 | rc = GO_TO_ROOT; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 724 | } |
| 725 | } |
| 726 | } |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 727 | return rc; |
| 728 | } |
| 729 | |
| 730 | int ft_exit(struct tree_context* c) |
| 731 | { |
| 732 | extern char lastfile[]; /* from tree.c */ |
| 733 | char buf[MAX_PATH]; |
| 734 | int rc = 0; |
| 735 | bool exit_func = false; |
| 736 | |
| 737 | int i = strlen(c->currdir); |
| 738 | if (i>1) { |
| 739 | while (c->currdir[i-1]!='/') |
| 740 | i--; |
| 741 | strcpy(buf,&c->currdir[i]); |
| 742 | if (i==1) |
| 743 | c->currdir[i]=0; |
| 744 | else |
| 745 | c->currdir[i-1]=0; |
| 746 | |
| 747 | if (*c->dirfilter > NUM_FILTER_MODES && c->dirlevel < 1) |
| 748 | exit_func = true; |
| 749 | |
| 750 | c->dirlevel--; |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 751 | if ( c->dirlevel < MAX_DIR_LEVELS ) |
| 752 | c->selected_item=c->selected_item_history[c->dirlevel]; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 753 | else |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 754 | c->selected_item=0; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 755 | |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 756 | /* if undefined position */ |
| 757 | if (c->selected_item == -1) |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 758 | strcpy(lastfile, buf); |
| 759 | } |
| 760 | else |
| 761 | { |
| 762 | if (*c->dirfilter > NUM_FILTER_MODES && c->dirlevel < 1) |
| 763 | exit_func = true; |
| 764 | } |
| 765 | |
| 766 | if (exit_func) |
Jens Arnold | 32be590 | 2005-05-17 18:28:32 +0000 | [diff] [blame] | 767 | rc = 3; |
Björn Stenberg | 8a5de5f | 2005-01-17 11:39:46 +0000 | [diff] [blame] | 768 | |
| 769 | return rc; |
| 770 | } |