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 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); |
diff --git a/apps/tagcache.c b/apps/tagcache.c index 302b6ad9de..9463d7c865 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 */ | ||
4867 | int success = false; | 4866 | int success = false; |
4867 | |||
4868 | DIR *dir = opendir(dirname); | 4868 | DIR *dir = opendir(dirname); |
4869 | if (!dir) | 4869 | if (!dir) |
4870 | { | 4870 | { |
@@ -4883,9 +4883,7 @@ 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; | 4886 | struct dirent *entry = readdir(dir); |
4887 | readdir_r(dir, &direntry, &entry); | ||
4888 | |||
4889 | if (entry == NULL) | 4887 | if (entry == NULL) |
4890 | { | 4888 | { |
4891 | success = true; | 4889 | success = true; |