summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2005-11-17 19:31:29 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2005-11-17 19:31:29 +0000
commit735f4537309d4a66e16dd020fa99149a9d5f8d29 (patch)
tree7326f1f8f45f43c40bc78b86e4809087dffa9aa7 /firmware
parentbc8a4e4b8cb613b7a0e4f348fe81086f92d9a994 (diff)
downloadrockbox-735f4537309d4a66e16dd020fa99149a9d5f8d29.tar.gz
rockbox-735f4537309d4a66e16dd020fa99149a9d5f8d29.zip
Added dircache support to playlist. Now playlist filename pointers are
automatically accuired from dircache. WPS UI response with dircache enabled should be instant. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7931 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/dircache.c41
-rw-r--r--firmware/include/dircache.h3
2 files changed, 44 insertions, 0 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index fa24321726..259c34cdf5 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -77,6 +77,7 @@ static struct dircache_entry* allocate_entry(void)
dircache_size += sizeof(struct dircache_entry);
next_entry->name_len = 0;
next_entry->d_name = NULL;
+ next_entry->up = NULL;
next_entry->down = NULL;
next_entry->next = NULL;
@@ -88,6 +89,7 @@ static struct dircache_entry* dircache_gen_next(struct dircache_entry *ce)
struct dircache_entry *next_entry;
next_entry = allocate_entry();
+ next_entry->up = ce->up;
ce->next = next_entry;
return next_entry;
@@ -98,6 +100,7 @@ static struct dircache_entry* dircache_gen_down(struct dircache_entry *ce)
struct dircache_entry *next_entry;
next_entry = allocate_entry();
+ next_entry->up = ce;
ce->down = next_entry;
return next_entry;
@@ -176,6 +179,7 @@ static int dircache_travel(struct fat_dir *dir, struct dircache_entry *ce)
int depth = 0;
int result;
+ memset(ce, 0, sizeof(struct dircache_entry));
dir_recursion[0].dir = dir;
dir_recursion[0].ce = ce;
@@ -517,6 +521,43 @@ void dircache_disable(void)
logf("Cache released");
}
+const struct dircache_entry *dircache_get_entry_ptr(const char *filename)
+{
+ if (!dircache_initialized || filename == NULL)
+ return NULL;
+
+ return dircache_get_entry(filename, false, false);
+}
+
+void dircache_copy_path(const struct dircache_entry *entry, char *buf, int size)
+{
+ const struct dircache_entry *down[MAX_SCAN_DEPTH];
+ int depth = 0;
+
+ if (size <= 0)
+ return ;
+
+ buf[0] = '\0';
+
+ if (entry == NULL)
+ return ;
+
+ do {
+ down[depth] = entry;
+ entry = entry->up;
+ depth++;
+ } while (entry != NULL && depth < MAX_SCAN_DEPTH);
+
+ while (--depth >= 0)
+ {
+ snprintf(buf, size, "/%s", down[depth]->d_name);
+ buf += down[depth]->name_len; /* '/' + d_name */
+ size -= down[depth]->name_len;
+ if (size <= 0)
+ break ;
+ }
+}
+
/* --- Directory cache live updating functions --- */
static struct dircache_entry* dircache_new_entry(const char *path, int attribute)
{
diff --git a/firmware/include/dircache.h b/firmware/include/dircache.h
index 48b74e0220..11d7335a31 100644
--- a/firmware/include/dircache.h
+++ b/firmware/include/dircache.h
@@ -47,6 +47,7 @@ struct dircache_maindata {
/* Exported structures. */
struct dircache_entry {
struct dircache_entry *next;
+ struct dircache_entry *up;
struct dircache_entry *down;
int attribute;
long size;
@@ -71,6 +72,8 @@ int dircache_build(int last_size);
bool dircache_is_enabled(void);
int dircache_get_cache_size(void);
void dircache_disable(void);
+const struct dircache_entry *dircache_get_entry_ptr(const char *filename);
+void dircache_copy_path(const struct dircache_entry *entry, char *buf, int size);
void dircache_bind(int fd, const char *path);
void dircache_update_filesize(int fd, long newsize);