From 84c7d8802106266c94d0a30827dff418a2fcac6d Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Tue, 18 Jan 2005 22:45:00 +0000 Subject: Added support for very large tables in ID3 database. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5595 a1c6a512-1295-4272-9138-f99709370657 --- apps/filetree.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'apps/filetree.c') 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) } /* load and sort directory into dircache. returns NULL on failure. */ -int ft_load(struct tree_context* c, bool *buffer_full) +int ft_load(struct tree_context* c) { - extern char lastdir[]; /* from tree.c */ int i; int name_buffer_used = 0; DIR *dir = opendir(c->currdir); @@ -194,13 +193,13 @@ int ft_load(struct tree_context* c, bool *buffer_full) return -1; /* not a directory */ c->dirsindir = 0; - if (buffer_full) - *buffer_full = false; + c->dirfull = false; for ( i=0; i < global_settings.max_files_in_dir; i++ ) { int len; struct dirent *entry = readdir(dir); - struct entry* dptr = (struct entry*)(c->dircache + i * sizeof(struct entry)); + struct entry* dptr = + (struct entry*)(c->dircache + i * sizeof(struct entry)); if (!entry) break; @@ -268,8 +267,7 @@ int ft_load(struct tree_context* c, bool *buffer_full) if (len > c->name_buffer_size - name_buffer_used - 1) { /* Tell the world that we ran out of buffer space */ - if (buffer_full) - *buffer_full = true; + c->dirfull = true; break; } dptr->name = &c->name_buffer[name_buffer_used]; @@ -281,10 +279,9 @@ int ft_load(struct tree_context* c, bool *buffer_full) c->dirsindir++; } c->filesindir = i; + c->dirlength = i; closedir(dir); - strcpy(lastdir, c->currdir); - qsort(c->dircache,i,sizeof(struct entry),compare); /* If thumbnail talking is enabled, make an extra run to mark files with -- cgit v1.2.3