mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
readdir_r use in tagcache.check_dir, ft_load
Change-Id: Ibcde39ed247e100dd47ae877fb2a3625bbb38d8b
This commit is contained in:
parent
f2f5543856
commit
0c737d3b2e
7 changed files with 129 additions and 24 deletions
|
@ -292,6 +292,7 @@ int ft_load(struct tree_context* c, const char* tempdir)
|
|||
|
||||
int files_in_dir = 0;
|
||||
int name_buffer_used = 0;
|
||||
struct dirent direntry;
|
||||
struct dirent *entry;
|
||||
bool (*callback_show_item)(char *, int, struct tree_context *) = NULL;
|
||||
DIR *dir;
|
||||
|
@ -313,7 +314,7 @@ int ft_load(struct tree_context* c, const char* tempdir)
|
|||
c->dirfull = false;
|
||||
|
||||
tree_lock_cache(c);
|
||||
while ((entry = readdir(dir))) {
|
||||
while (readdir_r(dir, &direntry, &entry) == 0 && entry) {
|
||||
int len;
|
||||
struct dirinfo info;
|
||||
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)
|
|||
info = dir_get_info(dir, entry);
|
||||
len = strlen((char *)entry->d_name);
|
||||
|
||||
/* skip directories . and .. */
|
||||
if ((info.attribute & ATTR_DIRECTORY) &&
|
||||
(((len == 1) && (!strncmp((char *)entry->d_name, ".", 1))) ||
|
||||
((len == 2) && (!strncmp((char *)entry->d_name, "..", 2))))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Skip FAT volume ID */
|
||||
if (info.attribute & ATTR_VOLUME_ID) {
|
||||
continue;
|
||||
}
|
||||
|
||||
dptr->attr = info.attribute;
|
||||
int dir_attr = (dptr->attr & ATTR_DIRECTORY);
|
||||
|
||||
/* skip directories . and .. */
|
||||
if (dir_attr && is_dotdir_name(entry->d_name))
|
||||
continue;
|
||||
|
||||
/* filter out dotfiles and hidden files */
|
||||
if (*c->dirfilter != SHOW_ALL &&
|
||||
((entry->d_name[0]=='.') ||
|
||||
|
@ -345,9 +346,6 @@ int ft_load(struct tree_context* c, const char* tempdir)
|
|||
continue;
|
||||
}
|
||||
|
||||
dptr->attr = info.attribute;
|
||||
int dir_attr = (dptr->attr & ATTR_DIRECTORY);
|
||||
|
||||
/* check for known file types */
|
||||
if ( !(dir_attr) )
|
||||
dptr->attr |= filetype_get_attr((char *)entry->d_name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue