diff options
author | Magnus Holmgren <magnushol@gmail.com> | 2011-05-04 18:33:12 +0000 |
---|---|---|
committer | Magnus Holmgren <magnushol@gmail.com> | 2011-05-04 18:33:12 +0000 |
commit | c2ff646b7870e34cfe97bf76c3689652f909b8e4 (patch) | |
tree | d624002222555512dff685e763e42c86b2e00315 /apps | |
parent | ffee0b5e94e565f94b7a312bcbee12d932b6e332 (diff) | |
download | rockbox-c2ff646b7870e34cfe97bf76c3689652f909b8e4.tar.gz rockbox-c2ff646b7870e34cfe97bf76c3689652f909b8e4.zip |
Avoid false warnings of full dirs when the number of visible entries in a dir equals the limit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29823 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/filetree.c | 24 | ||||
-rw-r--r-- | apps/tree.c | 2 |
2 files changed, 13 insertions, 13 deletions
diff --git a/apps/filetree.c b/apps/filetree.c index eaaee9644d..b7f3c9e981 100644 --- a/apps/filetree.c +++ b/apps/filetree.c | |||
@@ -267,8 +267,9 @@ static int compare(const void* p1, const void* p2) | |||
267 | /* load and sort directory into dircache. returns NULL on failure. */ | 267 | /* load and sort directory into dircache. returns NULL on failure. */ |
268 | int ft_load(struct tree_context* c, const char* tempdir) | 268 | int ft_load(struct tree_context* c, const char* tempdir) |
269 | { | 269 | { |
270 | int i; | 270 | int files_in_dir = 0; |
271 | int name_buffer_used = 0; | 271 | int name_buffer_used = 0; |
272 | struct dirent *entry; | ||
272 | bool (*callback_show_item)(char *, int, struct tree_context *) = NULL; | 273 | bool (*callback_show_item)(char *, int, struct tree_context *) = NULL; |
273 | DIR *dir; | 274 | DIR *dir; |
274 | 275 | ||
@@ -285,12 +286,11 @@ int ft_load(struct tree_context* c, const char* tempdir) | |||
285 | c->dirsindir = 0; | 286 | c->dirsindir = 0; |
286 | c->dirfull = false; | 287 | c->dirfull = false; |
287 | 288 | ||
288 | for ( i=0; i < c->dircache_count; i++ ) { | 289 | while ((entry = readdir(dir))) { |
289 | int len; | 290 | int len; |
290 | struct dirent *entry = readdir(dir); | ||
291 | struct dirinfo info; | 291 | struct dirinfo info; |
292 | struct entry* dptr = | 292 | struct entry* dptr = |
293 | (struct entry*)(c->dircache + i * sizeof(struct entry)); | 293 | (struct entry*)(c->dircache + files_in_dir * sizeof(struct entry)); |
294 | if (!entry) | 294 | if (!entry) |
295 | break; | 295 | break; |
296 | 296 | ||
@@ -301,13 +301,11 @@ int ft_load(struct tree_context* c, const char* tempdir) | |||
301 | if ((info.attribute & ATTR_DIRECTORY) && | 301 | if ((info.attribute & ATTR_DIRECTORY) && |
302 | (((len == 1) && (!strncmp((char *)entry->d_name, ".", 1))) || | 302 | (((len == 1) && (!strncmp((char *)entry->d_name, ".", 1))) || |
303 | ((len == 2) && (!strncmp((char *)entry->d_name, "..", 2))))) { | 303 | ((len == 2) && (!strncmp((char *)entry->d_name, "..", 2))))) { |
304 | i--; | ||
305 | continue; | 304 | continue; |
306 | } | 305 | } |
307 | 306 | ||
308 | /* Skip FAT volume ID */ | 307 | /* Skip FAT volume ID */ |
309 | if (info.attribute & ATTR_VOLUME_ID) { | 308 | if (info.attribute & ATTR_VOLUME_ID) { |
310 | i--; | ||
311 | continue; | 309 | continue; |
312 | } | 310 | } |
313 | 311 | ||
@@ -315,7 +313,6 @@ int ft_load(struct tree_context* c, const char* tempdir) | |||
315 | if (*c->dirfilter != SHOW_ALL && | 313 | if (*c->dirfilter != SHOW_ALL && |
316 | ((entry->d_name[0]=='.') || | 314 | ((entry->d_name[0]=='.') || |
317 | (info.attribute & ATTR_HIDDEN))) { | 315 | (info.attribute & ATTR_HIDDEN))) { |
318 | i--; | ||
319 | continue; | 316 | continue; |
320 | } | 317 | } |
321 | 318 | ||
@@ -359,15 +356,18 @@ int ft_load(struct tree_context* c, const char* tempdir) | |||
359 | (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_LUA) || | 356 | (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_LUA) || |
360 | (callback_show_item && !callback_show_item(entry->d_name, dptr->attr, c))) | 357 | (callback_show_item && !callback_show_item(entry->d_name, dptr->attr, c))) |
361 | { | 358 | { |
362 | i--; | ||
363 | continue; | 359 | continue; |
364 | } | 360 | } |
365 | 361 | ||
366 | if (len > c->name_buffer_size - name_buffer_used - 1) { | 362 | if ((len > c->name_buffer_size - name_buffer_used - 1) || |
363 | (files_in_dir >= c->dircache_count)) { | ||
367 | /* Tell the world that we ran out of buffer space */ | 364 | /* Tell the world that we ran out of buffer space */ |
368 | c->dirfull = true; | 365 | c->dirfull = true; |
369 | break; | 366 | break; |
370 | } | 367 | } |
368 | |||
369 | ++files_in_dir; | ||
370 | |||
371 | dptr->name = &c->name_buffer[name_buffer_used]; | 371 | dptr->name = &c->name_buffer[name_buffer_used]; |
372 | dptr->time_write = | 372 | dptr->time_write = |
373 | (long)info.wrtdate<<16 | | 373 | (long)info.wrtdate<<16 | |
@@ -378,12 +378,12 @@ int ft_load(struct tree_context* c, const char* tempdir) | |||
378 | if (dptr->attr & ATTR_DIRECTORY) /* count the remaining dirs */ | 378 | if (dptr->attr & ATTR_DIRECTORY) /* count the remaining dirs */ |
379 | c->dirsindir++; | 379 | c->dirsindir++; |
380 | } | 380 | } |
381 | c->filesindir = i; | 381 | c->filesindir = files_in_dir; |
382 | c->dirlength = i; | 382 | c->dirlength = files_in_dir; |
383 | closedir(dir); | 383 | closedir(dir); |
384 | 384 | ||
385 | compare_sort_dir = c->sort_dir; | 385 | compare_sort_dir = c->sort_dir; |
386 | qsort(c->dircache,i,sizeof(struct entry),compare); | 386 | qsort(c->dircache, files_in_dir, sizeof(struct entry), compare); |
387 | 387 | ||
388 | /* If thumbnail talking is enabled, make an extra run to mark files with | 388 | /* If thumbnail talking is enabled, make an extra run to mark files with |
389 | associated thumbnails, so we don't do unsuccessful spinups later. */ | 389 | associated thumbnails, so we don't do unsuccessful spinups later. */ |
diff --git a/apps/tree.c b/apps/tree.c index 44c4b92883..a9e6a6e840 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -390,7 +390,7 @@ static int update_dir(void) | |||
390 | #ifdef HAVE_TAGCACHE | 390 | #ifdef HAVE_TAGCACHE |
391 | !id3db && | 391 | !id3db && |
392 | #endif | 392 | #endif |
393 | (tc.dirfull || tc.filesindir == tc.dircache_count) ) | 393 | tc.dirfull ) |
394 | { | 394 | { |
395 | splash(HZ, ID2P(LANG_SHOWDIR_BUFFER_FULL)); | 395 | splash(HZ, ID2P(LANG_SHOWDIR_BUFFER_FULL)); |
396 | } | 396 | } |