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