summaryrefslogtreecommitdiff
path: root/apps/filetree.c
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2005-01-18 22:45:00 +0000
committerBjörn Stenberg <bjorn@haxx.se>2005-01-18 22:45:00 +0000
commit84c7d8802106266c94d0a30827dff418a2fcac6d (patch)
tree17a4d8a7f5375584783925dd3b44203245413755 /apps/filetree.c
parentf9c06226d6c3f756437dc45d573d23f14699e728 (diff)
downloadrockbox-84c7d8802106266c94d0a30827dff418a2fcac6d.tar.gz
rockbox-84c7d8802106266c94d0a30827dff418a2fcac6d.zip
Added support for very large tables in ID3 database.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5595 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/filetree.c')
-rw-r--r--apps/filetree.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/apps/filetree.c b/apps/filetree.c
index 09c2a2dcc0..a46ffbb2bc 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -184,9 +184,8 @@ static int compare(const void* p1, const void* p2)
184} 184}
185 185
186/* load and sort directory into dircache. returns NULL on failure. */ 186/* load and sort directory into dircache. returns NULL on failure. */
187int ft_load(struct tree_context* c, bool *buffer_full) 187int ft_load(struct tree_context* c)
188{ 188{
189 extern char lastdir[]; /* from tree.c */
190 int i; 189 int i;
191 int name_buffer_used = 0; 190 int name_buffer_used = 0;
192 DIR *dir = opendir(c->currdir); 191 DIR *dir = opendir(c->currdir);
@@ -194,13 +193,13 @@ int ft_load(struct tree_context* c, bool *buffer_full)
194 return -1; /* not a directory */ 193 return -1; /* not a directory */
195 194
196 c->dirsindir = 0; 195 c->dirsindir = 0;
197 if (buffer_full) 196 c->dirfull = false;
198 *buffer_full = false;
199 197
200 for ( i=0; i < global_settings.max_files_in_dir; i++ ) { 198 for ( i=0; i < global_settings.max_files_in_dir; i++ ) {
201 int len; 199 int len;
202 struct dirent *entry = readdir(dir); 200 struct dirent *entry = readdir(dir);
203 struct entry* dptr = (struct entry*)(c->dircache + i * sizeof(struct entry)); 201 struct entry* dptr =
202 (struct entry*)(c->dircache + i * sizeof(struct entry));
204 if (!entry) 203 if (!entry)
205 break; 204 break;
206 205
@@ -268,8 +267,7 @@ int ft_load(struct tree_context* c, bool *buffer_full)
268 267
269 if (len > c->name_buffer_size - name_buffer_used - 1) { 268 if (len > c->name_buffer_size - name_buffer_used - 1) {
270 /* Tell the world that we ran out of buffer space */ 269 /* Tell the world that we ran out of buffer space */
271 if (buffer_full) 270 c->dirfull = true;
272 *buffer_full = true;
273 break; 271 break;
274 } 272 }
275 dptr->name = &c->name_buffer[name_buffer_used]; 273 dptr->name = &c->name_buffer[name_buffer_used];
@@ -281,10 +279,9 @@ int ft_load(struct tree_context* c, bool *buffer_full)
281 c->dirsindir++; 279 c->dirsindir++;
282 } 280 }
283 c->filesindir = i; 281 c->filesindir = i;
282 c->dirlength = i;
284 closedir(dir); 283 closedir(dir);
285 284
286 strcpy(lastdir, c->currdir);
287
288 qsort(c->dircache,i,sizeof(struct entry),compare); 285 qsort(c->dircache,i,sizeof(struct entry),compare);
289 286
290 /* If thumbnail talking is enabled, make an extra run to mark files with 287 /* If thumbnail talking is enabled, make an extra run to mark files with