diff options
author | William Wilgus <wilgus.william@gmail.com> | 2024-05-01 10:01:56 -0400 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2024-05-02 09:33:29 -0400 |
commit | 0c737d3b2e4728347cf4d52025f9fc2ebbee6e90 (patch) | |
tree | 52d09ce760fb38e4f8f4752556a94a5f478cbc2f /apps/filetree.c | |
parent | f2f5543856b91b664bb124b3e9fcfb519f53cb33 (diff) | |
download | rockbox-0c737d3b2e4728347cf4d52025f9fc2ebbee6e90.tar.gz rockbox-0c737d3b2e4728347cf4d52025f9fc2ebbee6e90.zip |
readdir_r use in tagcache.check_dir, ft_load
Change-Id: Ibcde39ed247e100dd47ae877fb2a3625bbb38d8b
Diffstat (limited to 'apps/filetree.c')
-rw-r--r-- | apps/filetree.c | 20 |
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); |