diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2005-11-17 19:31:29 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2005-11-17 19:31:29 +0000 |
commit | 735f4537309d4a66e16dd020fa99149a9d5f8d29 (patch) | |
tree | 7326f1f8f45f43c40bc78b86e4809087dffa9aa7 /firmware/common | |
parent | bc8a4e4b8cb613b7a0e4f348fe81086f92d9a994 (diff) | |
download | rockbox-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/common')
-rw-r--r-- | firmware/common/dircache.c | 41 |
1 files changed, 41 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) | |||
77 | dircache_size += sizeof(struct dircache_entry); | 77 | dircache_size += sizeof(struct dircache_entry); |
78 | next_entry->name_len = 0; | 78 | next_entry->name_len = 0; |
79 | next_entry->d_name = NULL; | 79 | next_entry->d_name = NULL; |
80 | next_entry->up = NULL; | ||
80 | next_entry->down = NULL; | 81 | next_entry->down = NULL; |
81 | next_entry->next = NULL; | 82 | next_entry->next = NULL; |
82 | 83 | ||
@@ -88,6 +89,7 @@ static struct dircache_entry* dircache_gen_next(struct dircache_entry *ce) | |||
88 | struct dircache_entry *next_entry; | 89 | struct dircache_entry *next_entry; |
89 | 90 | ||
90 | next_entry = allocate_entry(); | 91 | next_entry = allocate_entry(); |
92 | next_entry->up = ce->up; | ||
91 | ce->next = next_entry; | 93 | ce->next = next_entry; |
92 | 94 | ||
93 | return next_entry; | 95 | return next_entry; |
@@ -98,6 +100,7 @@ static struct dircache_entry* dircache_gen_down(struct dircache_entry *ce) | |||
98 | struct dircache_entry *next_entry; | 100 | struct dircache_entry *next_entry; |
99 | 101 | ||
100 | next_entry = allocate_entry(); | 102 | next_entry = allocate_entry(); |
103 | next_entry->up = ce; | ||
101 | ce->down = next_entry; | 104 | ce->down = next_entry; |
102 | 105 | ||
103 | return next_entry; | 106 | return next_entry; |
@@ -176,6 +179,7 @@ static int dircache_travel(struct fat_dir *dir, struct dircache_entry *ce) | |||
176 | int depth = 0; | 179 | int depth = 0; |
177 | int result; | 180 | int result; |
178 | 181 | ||
182 | memset(ce, 0, sizeof(struct dircache_entry)); | ||
179 | dir_recursion[0].dir = dir; | 183 | dir_recursion[0].dir = dir; |
180 | dir_recursion[0].ce = ce; | 184 | dir_recursion[0].ce = ce; |
181 | 185 | ||
@@ -517,6 +521,43 @@ void dircache_disable(void) | |||
517 | logf("Cache released"); | 521 | logf("Cache released"); |
518 | } | 522 | } |
519 | 523 | ||
524 | const struct dircache_entry *dircache_get_entry_ptr(const char *filename) | ||
525 | { | ||
526 | if (!dircache_initialized || filename == NULL) | ||
527 | return NULL; | ||
528 | |||
529 | return dircache_get_entry(filename, false, false); | ||
530 | } | ||
531 | |||
532 | void dircache_copy_path(const struct dircache_entry *entry, char *buf, int size) | ||
533 | { | ||
534 | const struct dircache_entry *down[MAX_SCAN_DEPTH]; | ||
535 | int depth = 0; | ||
536 | |||
537 | if (size <= 0) | ||
538 | return ; | ||
539 | |||
540 | buf[0] = '\0'; | ||
541 | |||
542 | if (entry == NULL) | ||
543 | return ; | ||
544 | |||
545 | do { | ||
546 | down[depth] = entry; | ||
547 | entry = entry->up; | ||
548 | depth++; | ||
549 | } while (entry != NULL && depth < MAX_SCAN_DEPTH); | ||
550 | |||
551 | while (--depth >= 0) | ||
552 | { | ||
553 | snprintf(buf, size, "/%s", down[depth]->d_name); | ||
554 | buf += down[depth]->name_len; /* '/' + d_name */ | ||
555 | size -= down[depth]->name_len; | ||
556 | if (size <= 0) | ||
557 | break ; | ||
558 | } | ||
559 | } | ||
560 | |||
520 | /* --- Directory cache live updating functions --- */ | 561 | /* --- Directory cache live updating functions --- */ |
521 | static struct dircache_entry* dircache_new_entry(const char *path, int attribute) | 562 | static struct dircache_entry* dircache_new_entry(const char *path, int attribute) |
522 | { | 563 | { |