diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/filetree.c | 20 | ||||
-rw-r--r-- | apps/tagcache.c | 6 |
2 files changed, 13 insertions, 13 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); |
diff --git a/apps/tagcache.c b/apps/tagcache.c index 9463d7c865..302b6ad9de 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -4863,8 +4863,8 @@ static int free_search_roots(struct search_roots_ll * start) | |||
4863 | 4863 | ||
4864 | static bool check_dir(const char *dirname, int add_files) | 4864 | static bool check_dir(const char *dirname, int add_files) |
4865 | { | 4865 | { |
4866 | static struct dirent direntry; /* function is recursive, static uses less stack */ | ||
4866 | int success = false; | 4867 | int success = false; |
4867 | |||
4868 | DIR *dir = opendir(dirname); | 4868 | DIR *dir = opendir(dirname); |
4869 | if (!dir) | 4869 | if (!dir) |
4870 | { | 4870 | { |
@@ -4883,7 +4883,9 @@ static bool check_dir(const char *dirname, int add_files) | |||
4883 | /* Recursively scan the dir. */ | 4883 | /* Recursively scan the dir. */ |
4884 | while (!check_event_queue()) | 4884 | while (!check_event_queue()) |
4885 | { | 4885 | { |
4886 | struct dirent *entry = readdir(dir); | 4886 | struct dirent *entry; |
4887 | readdir_r(dir, &direntry, &entry); | ||
4888 | |||
4887 | if (entry == NULL) | 4889 | if (entry == NULL) |
4888 | { | 4890 | { |
4889 | success = true; | 4891 | success = true; |