summaryrefslogtreecommitdiff
path: root/apps/filetree.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/filetree.c')
-rw-r--r--apps/filetree.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/apps/filetree.c b/apps/filetree.c
index 99bb1340d7..b5f5dece5a 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -292,7 +292,6 @@ int ft_load(struct tree_context* c, const char* tempdir)
292 292
293 int files_in_dir = 0; 293 int files_in_dir = 0;
294 int name_buffer_used = 0; 294 int name_buffer_used = 0;
295 struct dirent direntry;
296 struct dirent *entry; 295 struct dirent *entry;
297 bool (*callback_show_item)(char *, int, struct tree_context *) = NULL; 296 bool (*callback_show_item)(char *, int, struct tree_context *) = NULL;
298 DIR *dir; 297 DIR *dir;
@@ -314,7 +313,7 @@ int ft_load(struct tree_context* c, const char* tempdir)
314 c->dirfull = false; 313 c->dirfull = false;
315 314
316 tree_lock_cache(c); 315 tree_lock_cache(c);
317 while (readdir_r(dir, &direntry, &entry) == 0 && entry) { 316 while ((entry = readdir(dir))) {
318 int len; 317 int len;
319 struct dirinfo info; 318 struct dirinfo info;
320 struct entry* dptr = tree_get_entry_at(c, files_in_dir); 319 struct entry* dptr = tree_get_entry_at(c, files_in_dir);
@@ -327,17 +326,17 @@ int ft_load(struct tree_context* c, const char* tempdir)
327 info = dir_get_info(dir, entry); 326 info = dir_get_info(dir, entry);
328 len = strlen((char *)entry->d_name); 327 len = strlen((char *)entry->d_name);
329 328
330 /* Skip FAT volume ID */ 329 /* skip directories . and .. */
331 if (info.attribute & ATTR_VOLUME_ID) { 330 if ((info.attribute & ATTR_DIRECTORY) &&
331 (((len == 1) && (!strncmp((char *)entry->d_name, ".", 1))) ||
332 ((len == 2) && (!strncmp((char *)entry->d_name, "..", 2))))) {
332 continue; 333 continue;
333 } 334 }
334 335
335 dptr->attr = info.attribute; 336 /* Skip FAT volume ID */
336 int dir_attr = (dptr->attr & ATTR_DIRECTORY); 337 if (info.attribute & ATTR_VOLUME_ID) {
337
338 /* skip directories . and .. */
339 if (dir_attr && is_dotdir_name(entry->d_name))
340 continue; 338 continue;
339 }
341 340
342 /* filter out dotfiles and hidden files */ 341 /* filter out dotfiles and hidden files */
343 if (*c->dirfilter != SHOW_ALL && 342 if (*c->dirfilter != SHOW_ALL &&
@@ -346,6 +345,9 @@ int ft_load(struct tree_context* c, const char* tempdir)
346 continue; 345 continue;
347 } 346 }
348 347
348 dptr->attr = info.attribute;
349 int dir_attr = (dptr->attr & ATTR_DIRECTORY);
350
349 /* check for known file types */ 351 /* check for known file types */
350 if ( !(dir_attr) ) 352 if ( !(dir_attr) )
351 dptr->attr |= filetype_get_attr((char *)entry->d_name); 353 dptr->attr |= filetype_get_attr((char *)entry->d_name);