vlc | branch: master | Rafaël Carré <[email protected]> | Mon Oct 25 21:43:30 2010 +0200| [3cc4799c1245eeab9e2fa2cfa94699d10cd7b0e1] | committer: Rafaël Carré
ncurses: factorize ReadDir() > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3cc4799c1245eeab9e2fa2cfa94699d10cd7b0e1 --- modules/gui/ncurses.c | 54 +++++++++++++++++------------------------------- 1 files changed, 19 insertions(+), 35 deletions(-) diff --git a/modules/gui/ncurses.c b/modules/gui/ncurses.c index e5d2ba5..0760d81 100644 --- a/modules/gui/ncurses.c +++ b/modules/gui/ncurses.c @@ -252,52 +252,36 @@ static void ReadDir(intf_thread_t *p_intf) struct stat stat_data; #endif struct dir_entry_t *p_dir_entry; - char *psz_uri; + char *psz_uri = NULL; - if (p_sys->b_show_hidden_files == false && - (strlen(psz_entry) && psz_entry[0] == '.') && - strcmp(psz_entry, "..")) - { - free(psz_entry); - continue; - } + if (!p_sys->b_show_hidden_files) + if (*psz_entry == '.' && strcmp(psz_entry, "..")) + goto next; - if (asprintf(&psz_uri, "%s/%s", p_sys->psz_current_dir, - psz_entry) == -1) + if (asprintf(&psz_uri, "%s/%s", p_sys->psz_current_dir, psz_entry) == -1) { - free(psz_entry); - continue; + psz_uri = NULL; + goto next; } - if (!(p_dir_entry = malloc(sizeof(struct dir_entry_t)))) - { - free(psz_uri); - free(psz_entry); - continue; - } + if (!(p_dir_entry = malloc(sizeof *p_dir_entry))) + goto next; + p_dir_entry->b_file = #if defined(S_ISDIR) - if (!vlc_stat(psz_uri, &stat_data) - && S_ISDIR(stat_data.st_mode)) + vlc_stat(psz_uri, &stat_data) || !S_ISDIR(stat_data.st_mode) /*#elif defined(DT_DIR) - if (p_dir_content->d_type & DT_DIR)*/ + !(p_dir_content->d_type & DT_DIR)*/ #else - if (0) + false #endif - { - p_dir_entry->psz_path = strdup(psz_entry); - p_dir_entry->b_file = false; - INSERT_ELEM(p_sys->pp_dir_entries, p_sys->i_dir_entries, - p_sys->i_dir_entries, p_dir_entry); - } - else - { - p_dir_entry->psz_path = strdup(psz_entry); - p_dir_entry->b_file = true; - INSERT_ELEM(p_sys->pp_dir_entries, p_sys->i_dir_entries, - p_sys->i_dir_entries, p_dir_entry); - } + ; + + p_dir_entry->psz_path = strdup(psz_entry); + INSERT_ELEM(p_sys->pp_dir_entries, p_sys->i_dir_entries, + p_sys->i_dir_entries, p_dir_entry); +next: free(psz_uri); free(psz_entry); } _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
