2002-05-16 12:53:40 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Daniel Stenberg
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-05-16 12:53:40 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2002-05-16 14:48:40 +00:00
|
|
|
#include <stdio.h>
|
2002-05-16 12:53:40 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
2010-05-06 21:04:40 +00:00
|
|
|
#include "string-extra.h"
|
2018-12-13 16:39:49 +00:00
|
|
|
#include "panic.h"
|
2002-05-16 12:53:40 +00:00
|
|
|
|
2002-08-15 12:28:52 +00:00
|
|
|
#include "applimits.h"
|
2002-05-16 12:53:40 +00:00
|
|
|
#include "dir.h"
|
|
|
|
#include "file.h"
|
|
|
|
#include "lcd.h"
|
2002-09-12 13:33:59 +00:00
|
|
|
#include "font.h"
|
2002-05-16 12:53:40 +00:00
|
|
|
#include "button.h"
|
|
|
|
#include "kernel.h"
|
2002-06-30 13:23:58 +00:00
|
|
|
#include "usb.h"
|
2002-05-16 12:53:40 +00:00
|
|
|
#include "tree.h"
|
2005-04-04 12:06:29 +00:00
|
|
|
#include "audio.h"
|
2002-06-07 14:23:32 +00:00
|
|
|
#include "playlist.h"
|
2002-06-14 10:39:11 +00:00
|
|
|
#include "menu.h"
|
2009-08-03 04:43:34 +00:00
|
|
|
#include "skin_engine/skin_engine.h"
|
2002-06-27 09:12:29 +00:00
|
|
|
#include "settings.h"
|
2002-06-30 13:23:58 +00:00
|
|
|
#include "debug.h"
|
2008-11-01 16:14:28 +00:00
|
|
|
#include "storage.h"
|
2002-09-03 09:44:08 +00:00
|
|
|
#include "rolo.h"
|
2002-09-03 07:53:51 +00:00
|
|
|
#include "icons.h"
|
2002-09-18 14:08:05 +00:00
|
|
|
#include "lang.h"
|
2002-09-24 17:22:12 +00:00
|
|
|
#include "screens.h"
|
2003-01-15 14:52:53 +00:00
|
|
|
#include "keyboard.h"
|
2004-01-14 00:13:04 +00:00
|
|
|
#include "bookmark.h"
|
2003-03-12 20:21:30 +00:00
|
|
|
#include "onplay.h"
|
2011-08-30 14:01:33 +00:00
|
|
|
#include "core_alloc.h"
|
2003-12-04 00:08:25 +00:00
|
|
|
#include "power.h"
|
2004-03-12 10:20:33 +00:00
|
|
|
#include "action.h"
|
2004-03-27 00:11:01 +00:00
|
|
|
#include "talk.h"
|
2004-05-21 20:08:24 +00:00
|
|
|
#include "filetypes.h"
|
2004-07-26 16:06:59 +00:00
|
|
|
#include "misc.h"
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
#include "pathfuncs.h"
|
2005-01-17 11:39:46 +00:00
|
|
|
#include "filetree.h"
|
2006-03-26 11:33:42 +00:00
|
|
|
#include "tagtree.h"
|
2006-11-06 18:07:30 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
2005-02-04 10:37:21 +00:00
|
|
|
#include "recorder/recording.h"
|
2006-11-06 18:07:30 +00:00
|
|
|
#endif
|
2005-02-05 19:57:19 +00:00
|
|
|
#include "rtc.h"
|
2005-10-07 17:38:05 +00:00
|
|
|
#include "dircache.h"
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-03-26 11:33:42 +00:00
|
|
|
#include "tagcache.h"
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2005-11-18 02:07:02 +00:00
|
|
|
#include "yesno.h"
|
2006-08-05 20:19:10 +00:00
|
|
|
#include "eeprom_settings.h"
|
2008-05-04 13:01:16 +00:00
|
|
|
#include "playlist_catalog.h"
|
2002-05-16 12:53:40 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* gui api */
|
|
|
|
#include "list.h"
|
|
|
|
#include "splash.h"
|
2008-05-03 12:30:40 +00:00
|
|
|
#include "quickscreen.h"
|
2009-09-20 00:04:39 +00:00
|
|
|
#include "appevents.h"
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
#include "root_menu.h"
|
2006-05-21 11:00:02 +00:00
|
|
|
|
2007-04-18 13:03:01 +00:00
|
|
|
static const struct filetype *filetypes;
|
|
|
|
static int filetypes_count;
|
2003-12-07 16:57:43 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
struct gui_synclist tree_lists;
|
|
|
|
|
|
|
|
/* I put it here because other files doesn't use it yet,
|
|
|
|
* but should be elsewhere since it will be used mostly everywhere */
|
2005-01-17 11:39:46 +00:00
|
|
|
static struct tree_context tc;
|
|
|
|
|
|
|
|
char lastfile[MAX_PATH];
|
2005-01-18 22:45:00 +00:00
|
|
|
static char lastdir[MAX_PATH];
|
2007-02-06 13:25:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-01-18 22:45:00 +00:00
|
|
|
static int lasttable, lastextra, lastfirstpos;
|
2007-02-06 13:25:57 +00:00
|
|
|
#endif
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2003-01-15 14:52:53 +00:00
|
|
|
static bool reload_dir = false;
|
2002-05-28 16:26:12 +00:00
|
|
|
|
2004-01-14 00:13:04 +00:00
|
|
|
static bool start_wps = false;
|
2005-10-28 00:00:00 +00:00
|
|
|
static int curr_context = false;/* id3db or tree*/
|
|
|
|
|
2007-03-17 00:55:23 +00:00
|
|
|
static int dirbrowse(void);
|
|
|
|
static int ft_play_dirname(char* name);
|
2018-10-30 13:45:26 +00:00
|
|
|
static int ft_play_filename(char *dir, char *file, int attr);
|
2007-10-21 00:20:51 +00:00
|
|
|
static void say_filetype(int attr);
|
2007-03-01 11:14:46 +00:00
|
|
|
|
2011-08-30 14:01:45 +00:00
|
|
|
struct entry* tree_get_entries(struct tree_context *t)
|
2011-08-03 09:49:25 +00:00
|
|
|
{
|
2011-08-30 14:01:45 +00:00
|
|
|
return core_get_data(t->cache.entries_handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct entry* tree_get_entry_at(struct tree_context *t, int index)
|
|
|
|
{
|
2018-12-13 16:39:49 +00:00
|
|
|
if(index < 0 || index >= t->cache.max_entries)
|
|
|
|
return NULL; /* no entry */
|
2011-08-30 14:01:45 +00:00
|
|
|
struct entry* entries = tree_get_entries(t);
|
2011-08-03 09:49:25 +00:00
|
|
|
return &entries[index];
|
|
|
|
}
|
|
|
|
|
2009-08-20 16:47:44 +00:00
|
|
|
static const char* tree_get_filename(int selected_item, void *data,
|
|
|
|
char *buffer, size_t buffer_len)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2005-10-29 02:33:19 +00:00
|
|
|
struct tree_context * local_tc=(struct tree_context *)data;
|
2005-10-28 00:00:00 +00:00
|
|
|
char *name;
|
|
|
|
int attr=0;
|
2007-08-13 23:11:30 +00:00
|
|
|
bool stripit = false;
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-10-29 02:33:19 +00:00
|
|
|
bool id3db = *(local_tc->dirfilter) == SHOW_ID3DB;
|
|
|
|
|
2006-04-15 13:57:15 +00:00
|
|
|
if (id3db)
|
|
|
|
{
|
2011-08-30 14:01:45 +00:00
|
|
|
return tagtree_get_entry_name(&tc, selected_item, buffer, buffer_len);
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
2021-10-21 20:42:01 +00:00
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2006-04-15 13:57:15 +00:00
|
|
|
{
|
2018-12-13 16:39:49 +00:00
|
|
|
struct entry *entry = tree_get_entry_at(local_tc, selected_item);
|
|
|
|
if (!entry)
|
2018-12-21 02:41:21 +00:00
|
|
|
panicf("Invalid tree entry %s", __func__);
|
2018-12-13 16:39:49 +00:00
|
|
|
name = entry->name;
|
|
|
|
attr = entry->attr;
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
2021-10-21 20:42:01 +00:00
|
|
|
|
2007-08-14 21:02:44 +00:00
|
|
|
if(!(attr & ATTR_DIRECTORY))
|
2007-08-13 23:11:30 +00:00
|
|
|
{
|
2007-08-14 21:02:44 +00:00
|
|
|
switch(global_settings.show_filename_ext)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
/* show file extension: off */
|
|
|
|
stripit = true;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
/* show file extension: on */
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* show file extension: only unknown types */
|
|
|
|
stripit = filetype_supported(attr);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
default:
|
|
|
|
/* show file extension: only when viewing all */
|
|
|
|
stripit = (*(local_tc->dirfilter) != SHOW_ID3DB) &&
|
|
|
|
(*(local_tc->dirfilter) != SHOW_ALL);
|
|
|
|
break;
|
|
|
|
}
|
2007-08-13 23:11:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(stripit)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2008-04-09 15:25:17 +00:00
|
|
|
return(strip_extension(buffer, buffer_len, name));
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
return(name);
|
|
|
|
}
|
|
|
|
|
2007-06-17 21:16:34 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
static int tree_get_filecolor(int selected_item, void * data)
|
|
|
|
{
|
2007-06-19 09:53:58 +00:00
|
|
|
if (*tc.dirfilter == SHOW_ID3DB)
|
|
|
|
return -1;
|
2007-06-17 21:16:34 +00:00
|
|
|
struct tree_context * local_tc=(struct tree_context *)data;
|
2018-12-13 16:39:49 +00:00
|
|
|
struct entry *entry = tree_get_entry_at(local_tc, selected_item);
|
|
|
|
if (!entry)
|
2018-12-21 02:41:21 +00:00
|
|
|
panicf("Invalid tree entry %s", __func__);
|
2018-12-13 16:39:49 +00:00
|
|
|
|
|
|
|
return filetype_get_color(entry->name, entry->attr);
|
2007-06-17 21:16:34 +00:00
|
|
|
}
|
|
|
|
#endif
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2009-07-11 00:22:26 +00:00
|
|
|
static enum themable_icons tree_get_fileicon(int selected_item, void * data)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2005-10-29 02:33:19 +00:00
|
|
|
struct tree_context * local_tc=(struct tree_context *)data;
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-10-29 02:33:19 +00:00
|
|
|
bool id3db = *(local_tc->dirfilter) == SHOW_ID3DB;
|
2005-10-28 00:00:00 +00:00
|
|
|
if (id3db) {
|
2007-04-16 09:14:36 +00:00
|
|
|
return tagtree_get_icon(&tc);
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
2006-10-25 10:17:57 +00:00
|
|
|
else
|
|
|
|
#endif
|
2011-08-03 09:49:25 +00:00
|
|
|
{
|
2018-12-13 16:39:49 +00:00
|
|
|
struct entry *entry = tree_get_entry_at(local_tc, selected_item);
|
|
|
|
if (!entry)
|
2018-12-21 02:41:21 +00:00
|
|
|
panicf("Invalid tree entry %s", __func__);
|
2018-12-13 16:39:49 +00:00
|
|
|
|
|
|
|
return filetype_get_icon(entry->attr);
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
2003-07-01 21:05:43 +00:00
|
|
|
|
2007-10-21 00:20:51 +00:00
|
|
|
static int tree_voice_cb(int selected_item, void * data)
|
|
|
|
{
|
|
|
|
struct tree_context * local_tc=(struct tree_context *)data;
|
|
|
|
char *name;
|
|
|
|
int attr=0;
|
|
|
|
#ifdef HAVE_TAGCACHE
|
|
|
|
bool id3db = *(local_tc->dirfilter) == SHOW_ID3DB;
|
2011-08-30 14:01:45 +00:00
|
|
|
char buf[AVERAGE_FILENAME_LENGTH*2];
|
2007-10-21 00:20:51 +00:00
|
|
|
|
|
|
|
if (id3db)
|
|
|
|
{
|
|
|
|
attr = tagtree_get_attr(local_tc);
|
2011-08-30 14:01:45 +00:00
|
|
|
name = tagtree_get_entry_name(local_tc, selected_item, buf, sizeof(buf));
|
2007-10-21 00:20:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2018-12-13 16:39:49 +00:00
|
|
|
struct entry *entry = tree_get_entry_at(local_tc, selected_item);
|
|
|
|
if (!entry)
|
2018-12-21 02:41:21 +00:00
|
|
|
panicf("Invalid tree entry %s", __func__);
|
2018-12-13 16:39:49 +00:00
|
|
|
|
|
|
|
name = entry->name;
|
|
|
|
attr = entry->attr;
|
2007-10-21 00:20:51 +00:00
|
|
|
}
|
|
|
|
bool is_dir = (attr & ATTR_DIRECTORY);
|
|
|
|
bool did_clip = false;
|
|
|
|
/* First the .talk clip case */
|
|
|
|
if(is_dir)
|
|
|
|
{
|
|
|
|
if(global_settings.talk_dir_clip)
|
|
|
|
{
|
|
|
|
did_clip = true;
|
2018-10-30 13:45:26 +00:00
|
|
|
if (ft_play_dirname(name) <= 0)
|
2007-10-21 00:20:51 +00:00
|
|
|
/* failed, not existing */
|
|
|
|
did_clip = false;
|
|
|
|
}
|
|
|
|
} else { /* it's a file */
|
|
|
|
if (global_settings.talk_file_clip && (attr & FILE_ATTR_THUMBNAIL))
|
|
|
|
{
|
|
|
|
did_clip = true;
|
2018-10-30 13:45:26 +00:00
|
|
|
if (ft_play_filename(local_tc->currdir, name, attr) <= 0)
|
|
|
|
/* failed, not existing */
|
|
|
|
did_clip = false;
|
2007-10-21 00:20:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!did_clip)
|
|
|
|
{
|
|
|
|
/* say the number or spell if required or as a fallback */
|
|
|
|
switch (is_dir ? global_settings.talk_dir : global_settings.talk_file)
|
|
|
|
{
|
|
|
|
case 1: /* as numbers */
|
|
|
|
talk_id(is_dir ? VOICE_DIR : VOICE_FILE, false);
|
|
|
|
talk_number(selected_item+1 - (is_dir ? 0 : local_tc->dirsindir),
|
|
|
|
true);
|
2007-11-07 03:25:33 +00:00
|
|
|
if(global_settings.talk_filetype
|
|
|
|
&& !is_dir && *local_tc->dirfilter < NUM_FILTER_MODES)
|
2007-10-21 00:20:51 +00:00
|
|
|
say_filetype(attr);
|
|
|
|
break;
|
|
|
|
case 2: /* spelled */
|
2007-11-07 01:45:43 +00:00
|
|
|
talk_shutup();
|
2007-11-07 03:25:33 +00:00
|
|
|
if(global_settings.talk_filetype)
|
|
|
|
{
|
|
|
|
if(is_dir)
|
|
|
|
talk_id(VOICE_DIR, true);
|
|
|
|
else if(*local_tc->dirfilter < NUM_FILTER_MODES)
|
|
|
|
say_filetype(attr);
|
|
|
|
}
|
2007-11-07 01:45:43 +00:00
|
|
|
talk_spell(name, true);
|
2007-10-21 00:20:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-09-10 20:51:12 +00:00
|
|
|
bool check_rockboxdir(void)
|
2002-05-16 12:53:40 +00:00
|
|
|
{
|
2010-12-06 22:26:31 +00:00
|
|
|
if(!dir_exists(ROCKBOX_DIR))
|
2006-04-01 13:36:33 +00:00
|
|
|
{ /* No need to localise this message.
|
|
|
|
If .rockbox is missing, it wouldn't work anyway */
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
screens[i].clear_display();
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ*2, "No .rockbox directory");
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
screens[i].clear_display();
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ*2, "Installation incomplete");
|
2004-09-10 20:51:12 +00:00
|
|
|
return false;
|
2004-09-05 16:50:07 +00:00
|
|
|
}
|
2004-09-10 20:51:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-06-10 10:41:27 +00:00
|
|
|
/* do this really late in the init sequence */
|
|
|
|
void tree_gui_init(void)
|
2004-09-10 20:51:12 +00:00
|
|
|
{
|
|
|
|
check_rockboxdir();
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
strcpy(tc.currdir, "/");
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2008-03-26 03:35:24 +00:00
|
|
|
gui_synclist_init(&tree_lists, &tree_get_filename, &tc, false, 1, NULL);
|
2007-10-21 00:20:51 +00:00
|
|
|
gui_synclist_set_voice_callback(&tree_lists, tree_voice_cb);
|
2009-12-16 08:36:46 +00:00
|
|
|
gui_synclist_set_icon_callback(&tree_lists,
|
|
|
|
global_settings.show_icons?&tree_get_fileicon:NULL);
|
2007-06-17 21:16:34 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-03-05 09:58:30 +00:00
|
|
|
gui_synclist_set_color_callback(&tree_lists, &tree_get_filecolor);
|
2007-06-17 21:16:34 +00:00
|
|
|
#endif
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
2007-04-18 13:03:01 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
struct tree_context* tree_get_context(void)
|
|
|
|
{
|
|
|
|
return &tc;
|
|
|
|
}
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/*
|
|
|
|
* Returns the position of a given file in the current directory
|
|
|
|
* returns -1 if not found
|
|
|
|
*/
|
2006-12-25 14:01:47 +00:00
|
|
|
static int tree_get_file_position(char * filename)
|
2004-03-27 00:11:01 +00:00
|
|
|
{
|
2018-12-13 16:39:49 +00:00
|
|
|
int i, ret = -1;/* no file match, return undefined */
|
|
|
|
|
|
|
|
tree_lock_cache(&tc);
|
|
|
|
struct entry *entries = tree_get_entries(&tc);
|
2006-03-26 11:33:42 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* use lastfile to determine the selected item (default=0) */
|
|
|
|
for (i=0; i < tc.filesindir; i++)
|
2003-01-24 10:56:59 +00:00
|
|
|
{
|
2018-12-13 16:39:49 +00:00
|
|
|
if (!strcasecmp(entries[i].name, filename))
|
|
|
|
{
|
|
|
|
ret = i;
|
|
|
|
break;
|
|
|
|
}
|
2003-01-24 10:56:59 +00:00
|
|
|
}
|
2018-12-13 16:39:49 +00:00
|
|
|
tree_unlock_cache(&tc);
|
|
|
|
return(ret);
|
2004-03-16 13:44:56 +00:00
|
|
|
}
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/*
|
|
|
|
* Called when a new dir is loaded (for example when returning from other apps ...)
|
|
|
|
* also completely redraws the tree
|
|
|
|
*/
|
|
|
|
static int update_dir(void)
|
2002-05-16 12:53:40 +00:00
|
|
|
{
|
2007-11-20 13:53:29 +00:00
|
|
|
bool changed = false;
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-01-18 23:07:23 +00:00
|
|
|
bool id3db = *tc.dirfilter == SHOW_ID3DB;
|
2005-10-28 00:00:00 +00:00
|
|
|
/* Checks for changes */
|
2005-01-17 11:39:46 +00:00
|
|
|
if (id3db) {
|
2005-01-18 22:45:00 +00:00
|
|
|
if (tc.currtable != lasttable ||
|
|
|
|
tc.currextra != lastextra ||
|
2006-06-07 20:42:42 +00:00
|
|
|
tc.firstpos != lastfirstpos ||
|
|
|
|
reload_dir)
|
2005-01-18 22:45:00 +00:00
|
|
|
{
|
2006-03-26 11:33:42 +00:00
|
|
|
if (tagtree_load(&tc) < 0)
|
2005-01-18 22:45:00 +00:00
|
|
|
return -1;
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2005-01-18 22:45:00 +00:00
|
|
|
lasttable = tc.currtable;
|
|
|
|
lastextra = tc.currextra;
|
|
|
|
lastfirstpos = tc.firstpos;
|
2005-10-28 00:00:00 +00:00
|
|
|
changed = true;
|
2005-01-18 22:45:00 +00:00
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
2021-10-21 20:42:01 +00:00
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2007-11-20 13:53:29 +00:00
|
|
|
{
|
2017-09-07 10:27:54 +00:00
|
|
|
tc.sort_dir = global_settings.sort_dir;
|
2005-10-28 00:00:00 +00:00
|
|
|
/* if the tc.currdir has been changed, reload it ...*/
|
2007-11-20 13:53:29 +00:00
|
|
|
if (strncmp(tc.currdir, lastdir, sizeof(lastdir)) || reload_dir)
|
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
if (ft_load(&tc, NULL) < 0)
|
2005-01-17 11:39:46 +00:00
|
|
|
return -1;
|
2021-07-23 14:31:56 +00:00
|
|
|
strlcpy(lastdir, tc.currdir, MAX_PATH);
|
2005-10-28 00:00:00 +00:00
|
|
|
changed = true;
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
/* if selected item is undefined */
|
|
|
|
if (tc.selected_item == -1)
|
2005-01-18 22:45:00 +00:00
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
/* use lastfile to determine the selected item */
|
|
|
|
tc.selected_item = tree_get_file_position(lastfile);
|
2002-09-09 17:32:15 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* If the file doesn't exists, select the first one (default) */
|
|
|
|
if(tc.selected_item < 0)
|
|
|
|
tc.selected_item = 0;
|
|
|
|
changed = true;
|
2002-09-09 14:25:39 +00:00
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
if (changed)
|
2003-04-14 07:53:58 +00:00
|
|
|
{
|
2006-10-25 10:17:57 +00:00
|
|
|
if(
|
|
|
|
#ifdef HAVE_TAGCACHE
|
2021-10-21 20:42:01 +00:00
|
|
|
!id3db &&
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2011-05-04 18:33:12 +00:00
|
|
|
tc.dirfull )
|
2003-04-14 07:53:58 +00:00
|
|
|
{
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ, ID2P(LANG_SHOWDIR_BUFFER_FULL));
|
2002-09-03 20:47:23 +00:00
|
|
|
}
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2020-07-17 14:31:31 +00:00
|
|
|
if (id3db)
|
2006-09-19 12:36:21 +00:00
|
|
|
{
|
|
|
|
if (global_settings.show_path_in_browser == SHOW_PATH_FULL
|
|
|
|
|| global_settings.show_path_in_browser == SHOW_PATH_CURRENT)
|
|
|
|
{
|
|
|
|
gui_synclist_set_title(&tree_lists, tagtree_get_title(&tc),
|
2007-03-01 18:25:13 +00:00
|
|
|
filetype_get_icon(ATTR_DIRECTORY));
|
2006-09-19 12:36:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Must clear the title as the list is reused */
|
|
|
|
gui_synclist_set_title(&tree_lists, NULL, NOICON);
|
2020-07-17 14:31:31 +00:00
|
|
|
}
|
2006-09-19 12:36:21 +00:00
|
|
|
}
|
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2006-09-19 12:36:21 +00:00
|
|
|
{
|
2010-12-14 13:37:58 +00:00
|
|
|
if (tc.browse && tc.browse->title)
|
2007-08-16 13:55:37 +00:00
|
|
|
{
|
2010-12-14 13:37:58 +00:00
|
|
|
int icon = tc.browse->icon;
|
|
|
|
if (icon == NOICON)
|
|
|
|
icon = filetype_get_icon(ATTR_DIRECTORY);
|
|
|
|
gui_synclist_set_title(&tree_lists, tc.browse->title, icon);
|
2007-08-16 13:55:37 +00:00
|
|
|
}
|
|
|
|
else if (global_settings.show_path_in_browser == SHOW_PATH_FULL)
|
2006-08-23 20:02:06 +00:00
|
|
|
{
|
|
|
|
gui_synclist_set_title(&tree_lists, tc.currdir,
|
2007-03-01 18:25:13 +00:00
|
|
|
filetype_get_icon(ATTR_DIRECTORY));
|
2006-08-23 20:02:06 +00:00
|
|
|
}
|
|
|
|
else if (global_settings.show_path_in_browser == SHOW_PATH_CURRENT)
|
|
|
|
{
|
|
|
|
char *title = strrchr(tc.currdir, '/') + 1;
|
|
|
|
if (*title == '\0')
|
|
|
|
{
|
2007-03-01 17:34:49 +00:00
|
|
|
/* Display "Files" for the root dir */
|
|
|
|
gui_synclist_set_title(&tree_lists, str(LANG_DIR_BROWSER),
|
2007-03-01 18:25:13 +00:00
|
|
|
filetype_get_icon(ATTR_DIRECTORY));
|
2006-08-23 20:02:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
gui_synclist_set_title(&tree_lists, title,
|
2007-03-01 18:25:13 +00:00
|
|
|
filetype_get_icon(ATTR_DIRECTORY));
|
2006-08-15 12:23:55 +00:00
|
|
|
}
|
2006-08-23 20:02:06 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Must clear the title as the list is reused */
|
|
|
|
gui_synclist_set_title(&tree_lists, NULL, NOICON);
|
2020-07-17 14:31:31 +00:00
|
|
|
}
|
2006-08-15 09:38:13 +00:00
|
|
|
}
|
2020-07-15 23:40:55 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_synclist_set_nb_items(&tree_lists, tc.filesindir);
|
2009-12-16 08:36:46 +00:00
|
|
|
gui_synclist_set_icon_callback(&tree_lists,
|
|
|
|
global_settings.show_icons?tree_get_fileicon:NULL);
|
2005-11-09 01:17:57 +00:00
|
|
|
if( tc.selected_item >= tc.filesindir)
|
|
|
|
tc.selected_item=tc.filesindir-1;
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_synclist_select_item(&tree_lists, tc.selected_item);
|
2006-07-01 10:31:50 +00:00
|
|
|
gui_synclist_draw(&tree_lists);
|
2007-10-21 00:20:51 +00:00
|
|
|
gui_synclist_speak_item(&tree_lists);
|
2005-01-17 11:39:46 +00:00
|
|
|
return tc.filesindir;
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
2003-07-01 21:05:43 +00:00
|
|
|
/* load tracks from specified directory to resume play */
|
2004-08-18 01:09:31 +00:00
|
|
|
void resume_directory(const char *dir)
|
2003-07-01 21:05:43 +00:00
|
|
|
{
|
2010-02-07 18:38:47 +00:00
|
|
|
int dirfilter = *tc.dirfilter;
|
|
|
|
int ret;
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-04-03 18:52:58 +00:00
|
|
|
bool id3db = *tc.dirfilter == SHOW_ID3DB;
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2010-02-07 18:38:47 +00:00
|
|
|
/* make sure the dirfilter is sane. The only time it should be possible
|
|
|
|
* thats its not is when resume playlist is called from a plugin
|
|
|
|
*/
|
2009-02-25 05:41:31 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2010-02-07 18:38:47 +00:00
|
|
|
if (!id3db)
|
2009-02-25 05:41:31 +00:00
|
|
|
#endif
|
2021-10-21 20:42:01 +00:00
|
|
|
*tc.dirfilter = global_settings.dirfilter;
|
2010-02-07 18:38:47 +00:00
|
|
|
ret = ft_load(&tc, dir);
|
|
|
|
*tc.dirfilter = dirfilter;
|
|
|
|
if (ret < 0)
|
2003-07-01 21:05:43 +00:00
|
|
|
return;
|
|
|
|
lastdir[0] = 0;
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
ft_build_playlist(&tc, 0);
|
2006-04-03 18:52:58 +00:00
|
|
|
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-04-03 18:52:58 +00:00
|
|
|
if (id3db)
|
|
|
|
tagtree_load(&tc);
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2003-07-01 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns the current working directory and also writes cwd to buf if
|
|
|
|
non-NULL. In case of error, returns NULL. */
|
2010-08-27 12:38:25 +00:00
|
|
|
char *getcwd(char *buf, getcwd_size_t size)
|
2003-07-01 21:05:43 +00:00
|
|
|
{
|
|
|
|
if (!buf)
|
2005-01-17 11:39:46 +00:00
|
|
|
return tc.currdir;
|
2010-08-27 10:33:09 +00:00
|
|
|
else if (size)
|
2003-07-01 21:05:43 +00:00
|
|
|
{
|
2010-08-27 12:38:25 +00:00
|
|
|
if ((getcwd_size_t)strlcpy(buf, tc.currdir, size) < size)
|
2010-08-27 10:33:09 +00:00
|
|
|
return buf;
|
2003-07-01 21:05:43 +00:00
|
|
|
}
|
2010-08-27 10:33:09 +00:00
|
|
|
/* size == 0, or truncation in strlcpy */
|
|
|
|
return NULL;
|
2003-07-01 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Force a reload of the directory next time directory browser is called */
|
|
|
|
void reload_directory(void)
|
|
|
|
{
|
|
|
|
reload_dir = true;
|
|
|
|
}
|
|
|
|
|
2010-08-27 10:33:09 +00:00
|
|
|
char* get_current_file(char* buffer, size_t buffer_len)
|
2007-03-06 08:21:18 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_TAGCACHE
|
|
|
|
/* in ID3DB mode it is a bad idea to call this function */
|
|
|
|
/* (only happens with `follow playlist') */
|
|
|
|
if( *tc.dirfilter == SHOW_ID3DB )
|
2010-08-27 10:33:09 +00:00
|
|
|
return NULL;
|
2007-03-06 08:21:18 +00:00
|
|
|
#endif
|
|
|
|
|
2018-12-13 16:39:49 +00:00
|
|
|
struct entry *entry = tree_get_entry_at(&tc, tc.selected_item);
|
|
|
|
if (entry && getcwd(buffer, buffer_len))
|
2010-08-27 10:33:09 +00:00
|
|
|
{
|
|
|
|
if (tc.dirlength)
|
|
|
|
{
|
2010-10-04 10:34:38 +00:00
|
|
|
if (buffer[strlen(buffer)-1] != '/')
|
|
|
|
strlcat(buffer, "/", buffer_len);
|
2018-12-13 16:39:49 +00:00
|
|
|
if (strlcat(buffer, entry->name, buffer_len) >= buffer_len)
|
2010-08-27 10:33:09 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
return NULL;
|
2007-03-06 08:21:18 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 20:42:01 +00:00
|
|
|
/* Allow apps to change our dirfilter directly (required for sub browsers)
|
2007-08-05 12:14:07 +00:00
|
|
|
if they're suddenly going to become a file browser for example */
|
|
|
|
void set_dirfilter(int l_dirfilter)
|
|
|
|
{
|
|
|
|
*tc.dirfilter = l_dirfilter;
|
|
|
|
}
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* Selects a file and update tree context properly */
|
2010-10-22 12:50:14 +00:00
|
|
|
void set_current_file(const char *path)
|
2002-09-09 14:25:39 +00:00
|
|
|
{
|
2010-10-22 12:50:14 +00:00
|
|
|
const char *name;
|
2005-10-28 00:00:00 +00:00
|
|
|
int i;
|
2002-09-09 14:25:39 +00:00
|
|
|
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-03-11 08:18:28 +00:00
|
|
|
/* in ID3DB mode it is a bad idea to call this function */
|
|
|
|
/* (only happens with `follow playlist') */
|
|
|
|
if( *tc.dirfilter == SHOW_ID3DB )
|
|
|
|
return;
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2005-03-11 08:18:28 +00:00
|
|
|
|
2002-09-09 14:25:39 +00:00
|
|
|
/* separate directory from filename */
|
2005-10-28 00:00:00 +00:00
|
|
|
/* gets the directory's name and put it into tc.currdir */
|
2002-09-17 07:42:21 +00:00
|
|
|
name = strrchr(path+1,'/');
|
2002-09-09 14:25:39 +00:00
|
|
|
if (name)
|
|
|
|
{
|
2010-10-22 12:50:14 +00:00
|
|
|
strlcpy(tc.currdir, path, name - path + 1);
|
2002-09-09 14:25:39 +00:00
|
|
|
name++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
strcpy(tc.currdir, "/");
|
2002-09-09 14:25:39 +00:00
|
|
|
name = path+1;
|
|
|
|
}
|
|
|
|
|
2021-07-23 14:31:56 +00:00
|
|
|
strlcpy(lastfile, name, MAX_PATH);
|
2006-04-10 03:51:17 +00:00
|
|
|
|
2002-09-09 14:25:39 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* If we changed dir we must recalculate the dirlevel
|
|
|
|
and adjust the selected history properly */
|
2005-01-17 11:39:46 +00:00
|
|
|
if (strncmp(tc.currdir,lastdir,sizeof(lastdir)))
|
2002-09-09 14:25:39 +00:00
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
tc.dirlevel = 0;
|
|
|
|
tc.selected_item_history[tc.dirlevel] = -1;
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2002-09-09 14:25:39 +00:00
|
|
|
/* use '/' to calculate dirlevel */
|
2007-03-01 11:14:46 +00:00
|
|
|
for (i = 1; path[i] != '\0'; i++)
|
2002-09-09 14:25:39 +00:00
|
|
|
{
|
|
|
|
if (path[i] == '/')
|
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirlevel++;
|
2005-10-28 00:00:00 +00:00
|
|
|
tc.selected_item_history[tc.dirlevel] = -1;
|
2002-09-09 14:25:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-03-01 11:14:46 +00:00
|
|
|
if (ft_load(&tc, NULL) >= 0)
|
|
|
|
{
|
|
|
|
tc.selected_item = tree_get_file_position(lastfile);
|
|
|
|
}
|
2002-09-09 14:25:39 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 10:17:57 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* main loop, handles key events */
|
2010-12-14 13:37:58 +00:00
|
|
|
static int dirbrowse(void)
|
2002-05-16 12:53:40 +00:00
|
|
|
{
|
2002-08-08 12:06:38 +00:00
|
|
|
int numentries=0;
|
2002-07-15 22:46:38 +00:00
|
|
|
char buf[MAX_PATH];
|
2018-07-25 17:28:25 +00:00
|
|
|
int len;
|
2011-09-17 20:53:28 +00:00
|
|
|
int button;
|
|
|
|
int oldbutton;
|
2002-09-03 20:47:23 +00:00
|
|
|
bool reload_root = false;
|
2005-01-17 11:39:46 +00:00
|
|
|
int lastfilter = *tc.dirfilter;
|
2002-09-03 20:47:23 +00:00
|
|
|
bool lastsortcase = global_settings.sort_case;
|
2003-09-29 21:26:53 +00:00
|
|
|
bool exit_func = false;
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
char* currdir = tc.currdir; /* just a shortcut */
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-01-18 23:07:23 +00:00
|
|
|
bool id3db = *tc.dirfilter == SHOW_ID3DB;
|
2003-01-24 10:56:59 +00:00
|
|
|
|
2005-06-23 01:31:26 +00:00
|
|
|
if (id3db)
|
|
|
|
curr_context=CONTEXT_ID3DB;
|
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2005-06-23 01:31:26 +00:00
|
|
|
curr_context=CONTEXT_TREE;
|
2007-03-01 11:14:46 +00:00
|
|
|
if (tc.selected_item < 0)
|
|
|
|
tc.selected_item = 0;
|
2007-02-06 13:25:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2007-11-20 13:53:29 +00:00
|
|
|
tc.firstpos = 0;
|
2005-01-18 22:45:00 +00:00
|
|
|
lasttable = -1;
|
|
|
|
lastextra = -1;
|
|
|
|
lastfirstpos = 0;
|
2007-02-06 13:25:57 +00:00
|
|
|
#endif
|
2002-09-09 14:25:39 +00:00
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
start_wps = false;
|
|
|
|
numentries = update_dir();
|
2007-10-21 00:20:51 +00:00
|
|
|
reload_dir = false;
|
2007-03-01 11:14:46 +00:00
|
|
|
if (numentries == -1)
|
2007-10-19 06:11:13 +00:00
|
|
|
return GO_TO_PREVIOUS; /* currdir is not a directory */
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
if (*tc.dirfilter > NUM_FILTER_MODES && numentries==0)
|
|
|
|
{
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ*2, ID2P(LANG_NO_FILES));
|
2010-12-14 13:37:58 +00:00
|
|
|
return GO_TO_PREVIOUS; /* No files found for rockbox_browse() */
|
2005-01-21 15:42:47 +00:00
|
|
|
}
|
2020-07-17 14:31:31 +00:00
|
|
|
|
Fix skin rendering issue entering dirbrowse
If the custom UI viewport (for displaying lists) changes size when entering dirbrowse, other viewports won't be correctly rendered and require a redraw.
The following is a minimal test case for an example SBS where (the specified background color for) the viewport at the top of the screen won't appear after the user has entered the (root menu of the) file or database browser:
%?if(%cs,=,1)<%VI(main)|%VI(other)>
%V(0,0,-,21,-)
%Vb(ededed)
%Vi(main,0,22,-,-,-)
%Vi(other,0,60,-,-,-)
Change-Id: I1aeed0561f16531802d0fb8dc5fd18d65ac8f25a
2021-02-23 20:14:41 +00:00
|
|
|
send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */
|
2009-01-15 06:24:58 +00:00
|
|
|
gui_synclist_draw(&tree_lists);
|
2002-05-16 12:53:40 +00:00
|
|
|
while(1) {
|
2002-06-25 13:26:04 +00:00
|
|
|
bool restore = false;
|
2007-03-01 11:14:46 +00:00
|
|
|
if (tc.dirlevel < 0)
|
2007-11-20 13:53:29 +00:00
|
|
|
tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */
|
2011-08-01 13:03:21 +00:00
|
|
|
|
2012-01-12 11:28:36 +00:00
|
|
|
keyclick_set_callback(gui_synclist_keyclick_callback, &tree_lists);
|
2021-03-14 19:03:00 +00:00
|
|
|
button = get_action(CONTEXT_TREE|ALLOW_SOFTLOCK,
|
2007-10-21 00:20:51 +00:00
|
|
|
list_do_action_timeout(&tree_lists, HZ/2));
|
2007-09-17 10:08:50 +00:00
|
|
|
oldbutton = button;
|
2007-10-21 00:20:51 +00:00
|
|
|
gui_synclist_do_button(&tree_lists, &button,LIST_WRAP_UNLESS_HELD);
|
2007-03-10 12:51:08 +00:00
|
|
|
tc.selected_item = gui_synclist_get_sel_pos(&tree_lists);
|
2002-07-27 20:55:39 +00:00
|
|
|
switch ( button ) {
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_OK:
|
2005-10-28 00:00:00 +00:00
|
|
|
/* nothing to do if no files to display */
|
|
|
|
if ( numentries == 0 )
|
2005-01-17 11:39:46 +00:00
|
|
|
break;
|
2018-12-21 02:41:21 +00:00
|
|
|
if (tc.browse->flags & BROWSE_SELECTONLY)
|
2010-12-14 13:37:58 +00:00
|
|
|
{
|
2018-12-21 02:41:21 +00:00
|
|
|
struct entry *entry = tree_get_entry_at(&tc, tc.selected_item);
|
|
|
|
if (!entry)
|
|
|
|
panicf("Invalid tree entry %s", __func__);
|
2010-12-14 13:37:58 +00:00
|
|
|
|
2018-12-21 02:41:21 +00:00
|
|
|
short attr = entry->attr;
|
|
|
|
if(!(attr & ATTR_DIRECTORY))
|
|
|
|
{
|
|
|
|
tc.browse->flags |= BROWSE_SELECTED;
|
|
|
|
get_current_file(tc.browse->buf, tc.browse->bufsize);
|
|
|
|
return GO_TO_PREVIOUS;
|
|
|
|
}
|
|
|
|
}
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-03-26 11:33:42 +00:00
|
|
|
switch (id3db?tagtree_enter(&tc):ft_enter(&tc))
|
2006-10-25 10:17:57 +00:00
|
|
|
#else
|
|
|
|
switch (ft_enter(&tc))
|
|
|
|
#endif
|
2005-01-20 16:24:26 +00:00
|
|
|
{
|
2010-08-16 13:16:29 +00:00
|
|
|
case GO_TO_FILEBROWSER: reload_dir = true; break;
|
2020-08-01 02:45:10 +00:00
|
|
|
case GO_TO_PLUGIN:
|
|
|
|
return GO_TO_PLUGIN;
|
2010-08-16 13:16:29 +00:00
|
|
|
case GO_TO_WPS:
|
|
|
|
return GO_TO_WPS;
|
|
|
|
#if CONFIG_TUNER
|
|
|
|
case GO_TO_FM:
|
|
|
|
return GO_TO_FM;
|
|
|
|
#endif
|
|
|
|
case GO_TO_ROOT: exit_func = true; break;
|
2005-01-20 16:24:26 +00:00
|
|
|
default: break;
|
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
restore = true;
|
|
|
|
break;
|
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_CANCEL:
|
2005-01-18 22:59:29 +00:00
|
|
|
if (*tc.dirfilter > NUM_FILTER_MODES && tc.dirlevel < 1) {
|
|
|
|
exit_func = true;
|
|
|
|
break;
|
|
|
|
}
|
2007-03-01 11:14:46 +00:00
|
|
|
if ((*tc.dirfilter == SHOW_ID3DB && tc.dirlevel == 0) ||
|
|
|
|
((*tc.dirfilter != SHOW_ID3DB && !strcmp(currdir,"/"))))
|
|
|
|
{
|
2007-09-17 10:08:50 +00:00
|
|
|
if (oldbutton == ACTION_TREE_PGLEFT)
|
2007-03-01 23:41:45 +00:00
|
|
|
break;
|
|
|
|
else
|
|
|
|
return GO_TO_ROOT;
|
2007-03-01 11:14:46 +00:00
|
|
|
}
|
2020-07-19 23:38:45 +00:00
|
|
|
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-08-15 21:27:04 +00:00
|
|
|
if (id3db)
|
|
|
|
tagtree_exit(&tc);
|
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2006-08-15 21:27:04 +00:00
|
|
|
if (ft_exit(&tc) == 3)
|
|
|
|
exit_func = true;
|
2021-10-21 20:42:01 +00:00
|
|
|
|
2006-08-15 21:27:04 +00:00
|
|
|
restore = true;
|
|
|
|
break;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_TREE_STOP:
|
2007-04-09 13:39:37 +00:00
|
|
|
if (list_stop_handler())
|
|
|
|
restore = true;
|
|
|
|
break;
|
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_MENU:
|
2007-03-01 13:01:14 +00:00
|
|
|
return GO_TO_ROOT;
|
2002-06-25 13:26:04 +00:00
|
|
|
break;
|
2002-05-21 14:30:54 +00:00
|
|
|
|
2007-08-02 12:13:20 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
case ACTION_STD_REC:
|
|
|
|
return GO_TO_RECSCREEN;
|
|
|
|
#endif
|
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_TREE_WPS:
|
2007-03-01 13:01:14 +00:00
|
|
|
return GO_TO_PREVIOUS_MUSIC;
|
2002-05-21 14:30:54 +00:00
|
|
|
break;
|
2006-04-10 03:51:17 +00:00
|
|
|
#ifdef HAVE_QUICKSCREEN
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_QUICKSCREEN:
|
2021-04-04 02:37:21 +00:00
|
|
|
if (global_settings.shortcuts_replaces_qs)
|
2003-11-04 16:47:05 +00:00
|
|
|
{
|
2021-04-04 02:37:21 +00:00
|
|
|
if (*tc.dirfilter < NUM_FILTER_MODES)
|
2021-03-07 15:07:49 +00:00
|
|
|
{
|
|
|
|
global_status.last_screen = GO_TO_SHORTCUTMENU;
|
|
|
|
return quick_screen_quick(button);
|
|
|
|
}
|
2021-04-04 02:37:21 +00:00
|
|
|
break;
|
2003-11-04 16:47:05 +00:00
|
|
|
}
|
2021-04-04 02:37:21 +00:00
|
|
|
else if (quick_screen_quick(button))
|
|
|
|
reload_dir = true;
|
|
|
|
restore = true;
|
2006-04-03 06:08:24 +00:00
|
|
|
break;
|
2005-06-26 20:16:26 +00:00
|
|
|
#endif
|
2004-10-05 00:08:04 +00:00
|
|
|
|
2010-05-09 02:07:42 +00:00
|
|
|
#ifdef HAVE_HOTKEY
|
2010-04-01 03:14:44 +00:00
|
|
|
case ACTION_TREE_HOTKEY:
|
2010-05-09 02:02:51 +00:00
|
|
|
if (!global_settings.hotkey_tree)
|
|
|
|
break;
|
|
|
|
/* fall through */
|
2010-05-09 02:07:42 +00:00
|
|
|
#endif
|
2010-05-09 02:02:51 +00:00
|
|
|
case ACTION_STD_CONTEXT:
|
2004-10-05 00:08:04 +00:00
|
|
|
{
|
2010-04-01 03:14:44 +00:00
|
|
|
bool hotkey = button == ACTION_TREE_HOTKEY;
|
2004-10-05 00:08:04 +00:00
|
|
|
int onplay_result;
|
2005-01-20 16:24:26 +00:00
|
|
|
int attr = 0;
|
2004-10-05 00:08:04 +00:00
|
|
|
|
2010-12-15 18:14:13 +00:00
|
|
|
if (tc.browse->flags & BROWSE_NO_CONTEXT_MENU)
|
2010-12-14 13:37:58 +00:00
|
|
|
break;
|
|
|
|
|
2004-10-05 00:08:04 +00:00
|
|
|
if(!numentries)
|
2010-04-01 03:14:44 +00:00
|
|
|
onplay_result = onplay(NULL, 0, curr_context, hotkey);
|
2004-10-05 00:08:04 +00:00
|
|
|
else {
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-06-23 01:31:26 +00:00
|
|
|
if (id3db)
|
2005-08-30 07:52:36 +00:00
|
|
|
{
|
2007-04-18 13:03:01 +00:00
|
|
|
if (tagtree_get_attr(&tc) == FILE_ATTR_AUDIO)
|
2005-06-23 01:31:26 +00:00
|
|
|
{
|
2007-04-18 13:03:01 +00:00
|
|
|
attr = FILE_ATTR_AUDIO;
|
2006-05-05 07:01:43 +00:00
|
|
|
tagtree_get_filename(&tc, buf, sizeof(buf));
|
2005-06-23 01:31:26 +00:00
|
|
|
}
|
2006-07-25 07:41:00 +00:00
|
|
|
else
|
|
|
|
attr = ATTR_DIRECTORY;
|
2005-08-30 07:52:36 +00:00
|
|
|
}
|
2005-06-23 01:31:26 +00:00
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2005-08-30 07:52:36 +00:00
|
|
|
{
|
2011-08-30 14:01:45 +00:00
|
|
|
struct entry *entry = tree_get_entry_at(&tc, tc.selected_item);
|
2018-12-13 16:39:49 +00:00
|
|
|
if (!entry)
|
2018-12-21 02:41:21 +00:00
|
|
|
panicf("Invalid tree entry %s", __func__);
|
2018-12-13 16:39:49 +00:00
|
|
|
|
2011-08-30 14:01:45 +00:00
|
|
|
attr = entry->attr;
|
2005-08-30 07:52:36 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
if (currdir[1]) /* Not in / */
|
2018-07-25 17:28:25 +00:00
|
|
|
{
|
|
|
|
len = snprintf(buf, sizeof buf, "%s/%s",
|
2011-08-30 14:01:45 +00:00
|
|
|
currdir, entry->name);
|
2018-07-25 17:28:25 +00:00
|
|
|
|
|
|
|
if ((unsigned) len > sizeof(buf))
|
|
|
|
splash(HZ, ID2P(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR));
|
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
else /* In / */
|
2011-08-30 14:01:45 +00:00
|
|
|
snprintf(buf, sizeof buf, "/%s", entry->name);
|
2005-08-30 07:52:36 +00:00
|
|
|
}
|
2010-04-01 03:14:44 +00:00
|
|
|
onplay_result = onplay(buf, attr, curr_context, hotkey);
|
2004-10-05 00:08:04 +00:00
|
|
|
}
|
|
|
|
switch (onplay_result)
|
|
|
|
{
|
2007-03-01 11:14:46 +00:00
|
|
|
case ONPLAY_MAINMENU:
|
|
|
|
return GO_TO_ROOT;
|
2021-10-28 01:45:24 +00:00
|
|
|
break;
|
2007-03-01 11:14:46 +00:00
|
|
|
|
2004-10-05 00:08:04 +00:00
|
|
|
case ONPLAY_OK:
|
|
|
|
restore = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ONPLAY_RELOAD_DIR:
|
|
|
|
reload_dir = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ONPLAY_START_PLAY:
|
2007-03-01 11:14:46 +00:00
|
|
|
return GO_TO_WPS;
|
2004-10-05 00:08:04 +00:00
|
|
|
break;
|
2021-10-28 01:45:24 +00:00
|
|
|
|
|
|
|
case ONPLAY_PLUGIN:
|
|
|
|
return GO_TO_PLUGIN;
|
|
|
|
break;
|
2004-10-05 00:08:04 +00:00
|
|
|
}
|
2004-05-21 20:08:24 +00:00
|
|
|
break;
|
2004-10-05 00:08:04 +00:00
|
|
|
}
|
2002-08-07 10:35:26 +00:00
|
|
|
|
2005-01-28 23:02:05 +00:00
|
|
|
#ifdef HAVE_HOTSWAP
|
|
|
|
case SYS_FS_CHANGED:
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-05-14 23:48:18 +00:00
|
|
|
if (!id3db)
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2005-10-28 00:00:00 +00:00
|
|
|
reload_dir = true;
|
2005-05-14 23:48:18 +00:00
|
|
|
/* The 'dir no longer valid' situation will be caught later
|
|
|
|
* by checking the showdir() result. */
|
2005-01-28 23:02:05 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2004-07-26 16:06:59 +00:00
|
|
|
default:
|
2005-09-14 09:07:05 +00:00
|
|
|
if (default_event_handler(button) == SYS_USB_CONNECTED)
|
2004-10-24 23:19:13 +00:00
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
if(*tc.dirfilter > NUM_FILTER_MODES)
|
2004-10-24 23:19:13 +00:00
|
|
|
/* leave sub-browsers after usb, doing otherwise
|
|
|
|
might be confusing to the user */
|
|
|
|
exit_func = true;
|
|
|
|
else
|
2005-05-16 11:50:46 +00:00
|
|
|
reload_dir = true;
|
2004-10-24 23:19:13 +00:00
|
|
|
}
|
2004-07-26 16:06:59 +00:00
|
|
|
break;
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
2007-03-01 11:14:46 +00:00
|
|
|
if (start_wps)
|
|
|
|
return GO_TO_WPS;
|
2009-01-01 13:12:37 +00:00
|
|
|
if (button && !IS_SYSEVENT(button))
|
2004-10-05 00:08:04 +00:00
|
|
|
{
|
2008-11-01 16:14:28 +00:00
|
|
|
storage_spin();
|
2004-10-05 00:08:04 +00:00
|
|
|
}
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2004-01-14 00:13:04 +00:00
|
|
|
|
2005-05-14 23:48:18 +00:00
|
|
|
check_rescan:
|
2002-09-03 20:47:23 +00:00
|
|
|
/* do we need to rescan dir? */
|
2003-03-07 08:10:10 +00:00
|
|
|
if (reload_dir || reload_root ||
|
2005-01-17 11:39:46 +00:00
|
|
|
lastfilter != *tc.dirfilter ||
|
2002-09-24 19:12:09 +00:00
|
|
|
lastsortcase != global_settings.sort_case)
|
2002-09-03 20:47:23 +00:00
|
|
|
{
|
2007-11-20 13:53:29 +00:00
|
|
|
if (reload_root) {
|
2002-09-03 20:47:23 +00:00
|
|
|
strcpy(currdir, "/");
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirlevel = 0;
|
2007-02-06 13:25:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-04-26 19:23:47 +00:00
|
|
|
tc.currtable = 0;
|
|
|
|
tc.currextra = 0;
|
|
|
|
lasttable = -1;
|
|
|
|
lastextra = -1;
|
2007-02-06 13:25:57 +00:00
|
|
|
#endif
|
2002-09-03 20:47:23 +00:00
|
|
|
reload_root = false;
|
|
|
|
}
|
2006-04-10 03:51:17 +00:00
|
|
|
|
2007-11-20 13:53:29 +00:00
|
|
|
if (!reload_dir)
|
2003-03-07 08:10:10 +00:00
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_synclist_select_item(&tree_lists, 0);
|
|
|
|
gui_synclist_draw(&tree_lists);
|
|
|
|
tc.selected_item = 0;
|
2003-03-07 08:10:10 +00:00
|
|
|
lastdir[0] = 0;
|
|
|
|
}
|
2003-09-29 21:26:53 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
lastfilter = *tc.dirfilter;
|
2002-09-03 20:47:23 +00:00
|
|
|
lastsortcase = global_settings.sort_case;
|
|
|
|
restore = true;
|
|
|
|
}
|
|
|
|
|
2003-09-29 21:26:53 +00:00
|
|
|
if (exit_func)
|
2007-03-01 11:14:46 +00:00
|
|
|
return GO_TO_PREVIOUS;
|
2003-09-29 21:26:53 +00:00
|
|
|
|
2003-01-15 14:52:53 +00:00
|
|
|
if (restore || reload_dir) {
|
2002-06-25 13:26:04 +00:00
|
|
|
/* restore display */
|
2005-10-28 00:00:00 +00:00
|
|
|
numentries = update_dir();
|
2007-10-21 00:20:51 +00:00
|
|
|
reload_dir = false;
|
2005-05-16 11:50:46 +00:00
|
|
|
if (currdir[1] && (numentries < 0))
|
2005-05-14 23:48:18 +00:00
|
|
|
{ /* not in root and reload failed */
|
|
|
|
reload_root = true; /* try root */
|
|
|
|
goto check_rescan;
|
|
|
|
}
|
2002-08-07 10:35:26 +00:00
|
|
|
}
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
2003-01-31 08:43:12 +00:00
|
|
|
return true;
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
2003-01-29 13:20:22 +00:00
|
|
|
|
2018-10-16 03:04:04 +00:00
|
|
|
int create_playlist(void)
|
2003-01-29 13:20:22 +00:00
|
|
|
{
|
2019-08-18 04:40:45 +00:00
|
|
|
bool ret;
|
|
|
|
#if 0 /* handled in catalog_add_to_a_playlist() */
|
2018-07-25 16:33:10 +00:00
|
|
|
char filename[MAX_PATH + 16]; /* add enough space for extension */
|
2019-08-17 14:06:14 +00:00
|
|
|
const char *playlist_dir = catalog_get_directory();
|
2019-08-18 04:40:45 +00:00
|
|
|
if (tc.currdir[1] && strcmp(tc.currdir, playlist_dir) != 0)
|
2011-07-20 14:11:15 +00:00
|
|
|
snprintf(filename, sizeof filename, "%s.m3u8", tc.currdir);
|
|
|
|
else
|
2019-08-17 14:06:14 +00:00
|
|
|
snprintf(filename, sizeof filename, "%s/all.m3u8", playlist_dir);
|
|
|
|
|
2020-07-21 06:33:53 +00:00
|
|
|
if (kbd_input(filename, MAX_PATH, NULL))
|
2018-10-16 03:04:04 +00:00
|
|
|
return 0;
|
2008-08-15 08:27:39 +00:00
|
|
|
splashf(0, "%s %s", str(LANG_CREATING), filename);
|
2019-08-18 04:40:45 +00:00
|
|
|
#endif
|
2003-01-29 13:20:22 +00:00
|
|
|
|
2006-11-11 05:33:24 +00:00
|
|
|
trigger_cpu_boost();
|
2019-08-18 04:40:45 +00:00
|
|
|
ret = catalog_add_to_a_playlist(tc.currdir, ATTR_DIRECTORY, true, NULL);
|
2007-11-20 03:44:25 +00:00
|
|
|
cancel_cpu_boost();
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2019-08-18 04:40:45 +00:00
|
|
|
return (ret) ? 1 : 0;
|
2003-01-29 13:20:22 +00:00
|
|
|
}
|
2003-05-09 16:01:21 +00:00
|
|
|
|
2010-12-14 13:37:58 +00:00
|
|
|
void browse_context_init(struct browse_context *browse,
|
|
|
|
int dirfilter, unsigned flags,
|
|
|
|
char *title, enum themable_icons icon,
|
|
|
|
const char *root, const char *selected)
|
|
|
|
{
|
|
|
|
browse->dirfilter = dirfilter;
|
|
|
|
browse->flags = flags;
|
|
|
|
browse->callback_show_item = NULL;
|
|
|
|
browse->title = title;
|
|
|
|
browse->icon = icon;
|
|
|
|
browse->root = root;
|
|
|
|
browse->selected = selected;
|
|
|
|
browse->buf = NULL;
|
|
|
|
browse->bufsize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NUM_TC_BACKUP 3
|
|
|
|
static struct tree_context backups[NUM_TC_BACKUP];
|
|
|
|
/* do not make backup if it is not recursive call */
|
|
|
|
static int backup_count = -1;
|
|
|
|
int rockbox_browse(struct browse_context *browse)
|
2003-09-29 21:26:53 +00:00
|
|
|
{
|
2010-10-22 12:50:14 +00:00
|
|
|
static char current[MAX_PATH];
|
2007-03-01 11:14:46 +00:00
|
|
|
int ret_val = 0;
|
2010-12-14 13:37:58 +00:00
|
|
|
int dirfilter = browse->dirfilter;
|
|
|
|
|
|
|
|
if (backup_count >= NUM_TC_BACKUP)
|
|
|
|
return GO_TO_PREVIOUS;
|
|
|
|
if (backup_count >= 0)
|
|
|
|
backups[backup_count] = tc;
|
|
|
|
backup_count++;
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirfilter = &dirfilter;
|
2008-10-08 16:32:01 +00:00
|
|
|
tc.sort_dir = global_settings.sort_dir;
|
2010-12-14 13:37:58 +00:00
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
reload_dir = true;
|
2010-12-14 13:37:58 +00:00
|
|
|
if (*tc.dirfilter >= NUM_FILTER_MODES)
|
2007-03-01 11:14:46 +00:00
|
|
|
{
|
|
|
|
int last_context;
|
2010-12-14 13:37:58 +00:00
|
|
|
|
|
|
|
tc.browse = browse;
|
2007-03-06 08:21:18 +00:00
|
|
|
tc.selected_item = 0;
|
2007-03-01 11:14:46 +00:00
|
|
|
tc.dirlevel = 0;
|
2010-12-14 13:37:58 +00:00
|
|
|
strlcpy(tc.currdir, browse->root, sizeof(tc.currdir));
|
2007-03-01 11:14:46 +00:00
|
|
|
start_wps = false;
|
|
|
|
last_context = curr_context;
|
2010-07-25 16:27:41 +00:00
|
|
|
|
2010-12-14 13:37:58 +00:00
|
|
|
if (browse->selected)
|
2009-06-22 17:37:36 +00:00
|
|
|
{
|
2010-12-14 13:37:58 +00:00
|
|
|
snprintf(current, sizeof(current), "%s/%s",
|
|
|
|
browse->root, browse->selected);
|
2009-06-22 17:37:36 +00:00
|
|
|
set_current_file(current);
|
|
|
|
/* set_current_file changes dirlevel, change it back */
|
2021-10-21 20:42:01 +00:00
|
|
|
tc.dirlevel = 0;
|
2009-06-22 17:37:36 +00:00
|
|
|
}
|
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
ret_val = dirbrowse();
|
|
|
|
curr_context = last_context;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (dirfilter != SHOW_ID3DB)
|
|
|
|
tc.dirfilter = &global_settings.dirfilter;
|
2010-12-14 13:37:58 +00:00
|
|
|
tc.browse = browse;
|
2021-07-23 14:31:56 +00:00
|
|
|
strlcpy(current, browse->root, MAX_PATH);
|
2010-10-22 12:50:14 +00:00
|
|
|
set_current_file(current);
|
2011-11-15 13:22:02 +00:00
|
|
|
if (browse->flags&BROWSE_RUNFILE)
|
|
|
|
ret_val = ft_enter(&tc);
|
|
|
|
else
|
|
|
|
ret_val = dirbrowse();
|
2007-03-01 11:14:46 +00:00
|
|
|
}
|
2010-12-14 13:37:58 +00:00
|
|
|
backup_count--;
|
|
|
|
if (backup_count >= 0)
|
|
|
|
tc = backups[backup_count];
|
2007-03-01 11:14:46 +00:00
|
|
|
return ret_val;
|
2003-09-29 21:26:53 +00:00
|
|
|
}
|
|
|
|
|
2011-08-30 14:01:45 +00:00
|
|
|
static int move_callback(int handle, void* current, void* new)
|
|
|
|
{
|
|
|
|
struct tree_cache* cache = &tc.cache;
|
|
|
|
if (cache->lock_count > 0)
|
|
|
|
return BUFLIB_CB_CANNOT_MOVE;
|
|
|
|
|
2019-02-07 04:43:36 +00:00
|
|
|
ptrdiff_t diff = new - current;
|
2011-08-30 14:01:45 +00:00
|
|
|
/* FIX_PTR makes sure to not accidentally update static allocations */
|
|
|
|
#define FIX_PTR(x) \
|
2011-09-21 13:32:37 +00:00
|
|
|
{ if ((void*)x >= current && (void*)x < (current+cache->name_buffer_size)) x+= diff; }
|
2011-08-30 14:01:45 +00:00
|
|
|
|
|
|
|
if (handle == cache->name_buffer_handle)
|
|
|
|
{ /* update entry structs, *even if they are struct tagentry */
|
|
|
|
struct entry *this = core_get_data(cache->entries_handle);
|
|
|
|
struct entry *last = this + cache->max_entries;
|
|
|
|
for(; this < last; this++)
|
|
|
|
FIX_PTR(this->name);
|
|
|
|
}
|
|
|
|
/* nothing to do if entries moved */
|
|
|
|
return BUFLIB_CB_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct buflib_callbacks ops = {
|
|
|
|
.move_callback = move_callback,
|
|
|
|
.shrink_callback = NULL,
|
|
|
|
};
|
|
|
|
|
2007-06-10 10:41:27 +00:00
|
|
|
void tree_mem_init(void)
|
2003-05-09 16:01:21 +00:00
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
/* initialize tree context struct */
|
2011-08-03 09:49:25 +00:00
|
|
|
struct tree_cache* cache = &tc.cache;
|
2005-01-17 11:39:46 +00:00
|
|
|
memset(&tc, 0, sizeof(tc));
|
|
|
|
tc.dirfilter = &global_settings.dirfilter;
|
2008-10-08 16:32:01 +00:00
|
|
|
tc.sort_dir = global_settings.sort_dir;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2011-08-03 09:49:25 +00:00
|
|
|
cache->name_buffer_size = AVERAGE_FILENAME_LENGTH *
|
2011-04-30 11:00:26 +00:00
|
|
|
global_settings.max_files_in_dir;
|
2011-08-30 14:01:45 +00:00
|
|
|
cache->name_buffer_handle = core_alloc_ex("tree names",
|
|
|
|
cache->name_buffer_size,
|
|
|
|
&ops);
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2011-08-03 09:49:25 +00:00
|
|
|
cache->max_entries = global_settings.max_files_in_dir;
|
2011-08-30 14:01:45 +00:00
|
|
|
cache->entries_handle = core_alloc_ex("tree entries",
|
|
|
|
cache->max_entries*(sizeof(struct entry)),
|
|
|
|
&ops);
|
2007-04-18 13:03:01 +00:00
|
|
|
tree_get_filetypes(&filetypes, &filetypes_count);
|
2003-05-09 16:01:21 +00:00
|
|
|
}
|
2004-01-14 00:13:04 +00:00
|
|
|
|
2013-07-14 11:59:39 +00:00
|
|
|
bool bookmark_play(char *resume_file, int index, unsigned long elapsed,
|
|
|
|
unsigned long offset, int seed, char *filename)
|
2004-01-14 00:13:04 +00:00
|
|
|
{
|
2004-12-07 14:20:37 +00:00
|
|
|
int i;
|
2006-09-21 18:57:54 +00:00
|
|
|
char* suffix = strrchr(resume_file, '.');
|
2008-02-10 12:16:27 +00:00
|
|
|
bool started = false;
|
2004-01-14 00:13:04 +00:00
|
|
|
|
2006-09-21 18:57:54 +00:00
|
|
|
if (suffix != NULL &&
|
|
|
|
(!strcasecmp(suffix, ".m3u") || !strcasecmp(suffix, ".m3u8")))
|
2004-01-14 00:13:04 +00:00
|
|
|
{
|
2004-12-07 14:20:37 +00:00
|
|
|
/* Playlist playback */
|
2004-01-14 00:13:04 +00:00
|
|
|
char* slash;
|
2005-10-28 00:00:00 +00:00
|
|
|
/* check that the file exists */
|
2008-04-16 19:51:43 +00:00
|
|
|
if(!file_exists(resume_file))
|
2008-02-10 12:16:27 +00:00
|
|
|
return false;
|
2004-01-14 00:13:04 +00:00
|
|
|
|
|
|
|
slash = strrchr(resume_file,'/');
|
|
|
|
if (slash)
|
|
|
|
{
|
|
|
|
char* cp;
|
|
|
|
*slash=0;
|
|
|
|
|
|
|
|
cp=resume_file;
|
|
|
|
if (!cp[0])
|
|
|
|
cp="/";
|
|
|
|
|
|
|
|
if (playlist_create(cp, slash+1) != -1)
|
|
|
|
{
|
|
|
|
if (global_settings.playlist_shuffle)
|
|
|
|
playlist_shuffle(seed, -1);
|
2013-07-14 11:59:39 +00:00
|
|
|
playlist_start(index, elapsed, offset);
|
2008-02-10 12:16:27 +00:00
|
|
|
started = true;
|
2004-01-14 00:13:04 +00:00
|
|
|
}
|
|
|
|
*slash='/';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-07 14:20:37 +00:00
|
|
|
/* Directory playback */
|
2004-01-14 00:13:04 +00:00
|
|
|
lastdir[0]='\0';
|
|
|
|
if (playlist_create(resume_file, NULL) != -1)
|
|
|
|
{
|
2010-08-11 19:01:50 +00:00
|
|
|
char filename_buf[MAX_PATH + 1];
|
2010-05-07 16:35:37 +00:00
|
|
|
const char* peek_filename;
|
2004-01-14 00:13:04 +00:00
|
|
|
resume_directory(resume_file);
|
|
|
|
if (global_settings.playlist_shuffle)
|
|
|
|
playlist_shuffle(seed, -1);
|
2004-12-07 14:20:37 +00:00
|
|
|
|
|
|
|
/* Check if the file is at the same spot in the directory,
|
|
|
|
else search for it */
|
2010-08-11 19:01:50 +00:00
|
|
|
peek_filename = playlist_peek(index, filename_buf,
|
|
|
|
sizeof(filename_buf));
|
2021-10-21 20:42:01 +00:00
|
|
|
|
2007-04-12 19:11:39 +00:00
|
|
|
if (peek_filename == NULL)
|
2010-04-09 20:08:48 +00:00
|
|
|
{
|
2010-04-09 23:19:13 +00:00
|
|
|
/* playlist has shrunk, search from the top */
|
|
|
|
index = 0;
|
2010-08-11 19:01:50 +00:00
|
|
|
peek_filename = playlist_peek(index, filename_buf,
|
|
|
|
sizeof(filename_buf));
|
2010-04-09 20:08:48 +00:00
|
|
|
if (peek_filename == NULL)
|
|
|
|
return false;
|
|
|
|
}
|
2021-10-21 20:42:01 +00:00
|
|
|
|
2007-04-12 19:11:39 +00:00
|
|
|
if (strcmp(strrchr(peek_filename, '/') + 1, filename))
|
2004-12-07 14:20:37 +00:00
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
for ( i=0; i < playlist_amount(); i++ )
|
2004-12-07 14:20:37 +00:00
|
|
|
{
|
2010-08-11 19:01:50 +00:00
|
|
|
peek_filename = playlist_peek(i, filename_buf,
|
|
|
|
sizeof(filename_buf));
|
2007-04-12 19:11:39 +00:00
|
|
|
|
|
|
|
if (peek_filename == NULL)
|
2008-02-10 12:16:27 +00:00
|
|
|
return false;
|
2007-04-12 19:11:39 +00:00
|
|
|
|
|
|
|
if (!strcmp(strrchr(peek_filename, '/') + 1, filename))
|
2004-12-07 14:20:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i < playlist_amount())
|
|
|
|
index = i;
|
|
|
|
else
|
2008-02-10 12:16:27 +00:00
|
|
|
return false;
|
2004-12-07 14:20:37 +00:00
|
|
|
}
|
2013-07-14 11:59:39 +00:00
|
|
|
playlist_start(index, elapsed, offset);
|
2008-02-10 12:16:27 +00:00
|
|
|
started = true;
|
2004-01-14 00:13:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-10 12:16:27 +00:00
|
|
|
if (started)
|
|
|
|
start_wps = true;
|
|
|
|
return started;
|
2004-01-14 00:13:04 +00:00
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2018-10-30 13:45:26 +00:00
|
|
|
static long filetype_voiceclip(int attr)
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
2007-04-18 13:03:01 +00:00
|
|
|
int j;
|
2018-10-30 13:45:26 +00:00
|
|
|
if (global_settings.talk_filetype)
|
|
|
|
{
|
|
|
|
/* try to find a voice ID for the extension, if known */
|
|
|
|
attr &= FILE_ATTR_MASK; /* file type */
|
|
|
|
for (j=0; j<filetypes_count; j++)
|
|
|
|
if (attr == filetypes[j].tree_attr)
|
|
|
|
{
|
|
|
|
return filetypes[j].voiceclip;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void say_filetype(int attr)
|
|
|
|
{
|
|
|
|
talk_id(filetype_voiceclip(attr), true);
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
|
2007-03-17 00:55:23 +00:00
|
|
|
static int ft_play_dirname(char* name)
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
2018-10-30 13:45:26 +00:00
|
|
|
return talk_file(tc.currdir, name, dir_thumbnail_name, NULL,
|
|
|
|
global_settings.talk_filetype ?
|
|
|
|
TALK_IDARRAY(VOICE_DIR) : NULL,
|
|
|
|
false);
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
|
2018-10-30 13:45:26 +00:00
|
|
|
static int ft_play_filename(char *dir, char *file, int attr)
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
2008-09-02 08:15:44 +00:00
|
|
|
if (strlen(file) >= strlen(file_thumbnail_ext)
|
2008-07-15 14:55:31 +00:00
|
|
|
&& strcasecmp(&file[strlen(file) - strlen(file_thumbnail_ext)],
|
|
|
|
file_thumbnail_ext))
|
|
|
|
/* file has no .talk extension */
|
2018-10-30 13:45:26 +00:00
|
|
|
return talk_file(dir, NULL, file, file_thumbnail_ext,
|
|
|
|
TALK_IDARRAY(filetype_voiceclip(attr)), false);
|
|
|
|
|
|
|
|
/* it already is a .talk file, play this directly, but prefix it. */
|
|
|
|
return talk_file(dir, NULL, file, NULL,
|
|
|
|
TALK_IDARRAY(LANG_VOICE_DIR_HOVER), false);
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
|
2005-09-14 09:07:05 +00:00
|
|
|
/* These two functions are called by the USB and shutdown handlers */
|
|
|
|
void tree_flush(void)
|
|
|
|
{
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-09-23 10:29:14 +00:00
|
|
|
tagcache_shutdown();
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2006-03-26 11:33:42 +00:00
|
|
|
|
2006-08-09 07:41:28 +00:00
|
|
|
#ifdef HAVE_TC_RAMCACHE
|
|
|
|
tagcache_unload_ramcache();
|
|
|
|
#endif
|
2006-08-11 10:13:16 +00:00
|
|
|
|
2005-10-07 17:38:05 +00:00
|
|
|
#ifdef HAVE_DIRCACHE
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
int old_val = global_status.dircache_size;
|
|
|
|
#ifdef HAVE_EEPROM_SETTINGS
|
|
|
|
bool savecache = false;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (global_settings.dircache)
|
2005-10-07 17:38:05 +00:00
|
|
|
{
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
dircache_suspend();
|
|
|
|
|
|
|
|
struct dircache_info info;
|
|
|
|
dircache_get_info(&info);
|
|
|
|
|
|
|
|
global_status.dircache_size = info.last_size;
|
|
|
|
#ifdef HAVE_EEPROM_SETTINGS
|
|
|
|
savecache = firmware_settings.initialized;
|
2021-10-21 20:42:01 +00:00
|
|
|
#endif
|
2005-10-07 17:38:05 +00:00
|
|
|
}
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
global_status.dircache_size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (old_val != global_status.dircache_size)
|
|
|
|
status_save();
|
|
|
|
|
|
|
|
#ifdef HAVE_EEPROM_SETTINGS
|
|
|
|
if (savecache)
|
|
|
|
dircache_save();
|
|
|
|
#endif
|
|
|
|
#endif /* HAVE_DIRCACHE */
|
2005-09-14 09:07:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void tree_restore(void)
|
|
|
|
{
|
2006-08-15 22:54:06 +00:00
|
|
|
#ifdef HAVE_EEPROM_SETTINGS
|
2006-08-09 07:41:28 +00:00
|
|
|
firmware_settings.disk_clean = false;
|
|
|
|
#endif
|
2021-10-21 20:42:01 +00:00
|
|
|
|
2006-08-11 10:13:16 +00:00
|
|
|
#ifdef HAVE_TC_RAMCACHE
|
|
|
|
remove(TAGCACHE_STATEFILE);
|
|
|
|
#endif
|
2021-10-21 20:42:01 +00:00
|
|
|
|
2005-10-07 17:38:05 +00:00
|
|
|
#ifdef HAVE_DIRCACHE
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
if (global_settings.dircache && dircache_resume() > 0)
|
2005-10-19 11:34:32 +00:00
|
|
|
{
|
|
|
|
/* Print "Scanning disk..." to the display. */
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, str(LANG_SCANNING_DISK));
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
dircache_wait();
|
2005-10-19 11:34:32 +00:00
|
|
|
}
|
2005-10-07 17:38:05 +00:00
|
|
|
#endif
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-07-12 16:07:27 +00:00
|
|
|
tagcache_start_scan();
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2005-09-14 09:07:05 +00:00
|
|
|
}
|