diff --git a/src/subst/wildcard_exp.c b/src/subst/wildcard_exp.c index ee62d15..4ae2981 100644 --- a/src/subst/wildcard_exp.c +++ b/src/subst/wildcard_exp.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* wildcard_exp.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jguelen +#+ +:+ +#+ */ +/* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/20 15:01:38 by jguelen #+# #+# */ -/* Updated: 2025/03/21 18:42:04 by jguelen ### ########.fr */ +/* Updated: 2025/04/03 19:58:36 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -104,20 +104,17 @@ static t_wordlist *expand_star_core(t_worddesc *file_pattern) if (current_dir == NULL) return (NULL); file_wordlist = NULL; - errno = 0; new = readdir(current_dir); while (new) { if (fits_pattern(new->d_name, file_pattern)) { if (add_file_to_list(&file_wordlist, new->d_name) == NULL) - return (NULL); + return (closedir(current_dir), NULL); } - errno = 0; new = readdir(current_dir); } - if (errno) - return (wordlist_destroy(file_wordlist), NULL); + closedir(current_dir); if (!file_wordlist) file_wordlist = wordlist_independant_create(file_pattern); return (wordlist_quicksort_full(file_wordlist));