diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2005-10-07 17:38:05 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2005-10-07 17:38:05 +0000 |
commit | ab78b0468088e9011273edc32d59145db9030a7e (patch) | |
tree | 5dc785c1f3eec456592b210d1aad39b6f5cf6880 /apps/tree.c | |
parent | 86e31d5558704b8ab83d2e5d5c9dca691a5f768a (diff) |
Implemented directory caching. No more waiting for disk to spin up while
browsing when cache is enabled (system -> disk -> enable directory
cache). Cache building on boot is transparent except the first boot.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7588 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tree.c')
-rw-r--r-- | apps/tree.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/apps/tree.c b/apps/tree.c index a52d453081..bfaf7b8304 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -61,6 +61,7 @@ #include "dbtree.h" #include "recorder/recording.h" #include "rtc.h" +#include "dircache.h" #ifdef HAVE_LCD_BITMAP #include "widgets.h" @@ -1324,7 +1325,7 @@ static int plsize = 0; static bool add_dir(char* dirname, int len, int fd) { bool abort = false; - DIR* dir; + DIRCACHED* dir; /* check for user abort */ #ifdef BUTTON_STOP @@ -1334,14 +1335,14 @@ static bool add_dir(char* dirname, int len, int fd) #endif return true; - dir = opendir(dirname); + dir = opendir_cached(dirname); if(!dir) return true; while (true) { - struct dirent *entry; + struct dircache_entry *entry; - entry = readdir(dir); + entry = readdir_cached(dir); if (!entry) break; if (entry->attribute & ATTR_DIRECTORY) { @@ -1409,7 +1410,7 @@ static bool add_dir(char* dirname, int len, int fd) } } } - closedir(dir); + closedir_cached(dir); return abort; } @@ -1634,10 +1635,26 @@ void tree_flush(void) { rundb_shutdown(); tagdb_shutdown(); +#ifdef HAVE_DIRCACHE + if (global_settings.dircache) + { + global_settings.dircache_size = dircache_get_cache_size(); + dircache_disable(); + } + else + { + global_settings.dircache_size = 0; + } + settings_save(); +#endif } void tree_restore(void) { tagdb_init(); rundb_init(); +#ifdef HAVE_DIRCACHE + if (global_settings.dircache) + dircache_build(global_settings.dircache_size); +#endif } |