From e5393671a265e1c301c6c303f21f938c4cf9ca75 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 2 Apr 2020 15:50:13 +0200 Subject: Evaluation pipe frame (not tested) --- src/path.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/path.c') diff --git a/src/path.c b/src/path.c index f1424cc..1576a66 100644 --- a/src/path.c +++ b/src/path.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/27 15:51:01 by cacharle #+# #+# */ -/* Updated: 2020/04/01 17:55:28 by charles ### ########.fr */ +/* Updated: 2020/04/03 07:17:04 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,16 +35,19 @@ static t_path st_path_dir_update(t_path path, char *dirname) { DIR *dir; struct dirent *entry; - char *tmp; + char *filepath; if ((dir = opendir(dirname)) == NULL) return (NULL); while ((entry = readdir(dir)) != NULL) { - if ((tmp = ft_strjoin3(dirname, "/", entry->d_name)) == NULL) - return (NULL); - if (ft_htset(path, entry->d_name, tmp, ht_del_str_entry) == NULL) + if ((filepath = ft_strjoin3(dirname, "/", entry->d_name)) == NULL || + ft_htset(path, entry->d_name, filepath, free) == NULL) + { + free(filepath); + closedir(dir); return (NULL); + } } if (closedir(dir) == -1) return (NULL); -- cgit From c0e2ee28eedc1a9a886f9729a994d77738e2eb58 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 3 Apr 2020 15:13:08 +0200 Subject: Refactoring env, connecting pipes, preprocess draft --- src/path.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'src/path.c') diff --git a/src/path.c b/src/path.c index 1576a66..c9f184c 100644 --- a/src/path.c +++ b/src/path.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/27 15:51:01 by cacharle #+# #+# */ -/* Updated: 2020/04/03 07:17:04 by charles ### ########.fr */ +/* Updated: 2020/04/03 13:53:01 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,27 +31,17 @@ ** \return Same path or NULL on error */ -static t_path st_path_dir_update(t_path path, char *dirname) +static int st_add_file(char *dirname, struct dirent *entry, void *path) { - DIR *dir; - struct dirent *entry; - char *filepath; + char *filepath; - if ((dir = opendir(dirname)) == NULL) - return (NULL); - while ((entry = readdir(dir)) != NULL) + if ((filepath = ft_strjoin3(dirname, "/", entry->d_name)) == NULL || + ft_htset((t_path)path, entry->d_name, filepath, free) == NULL) { - if ((filepath = ft_strjoin3(dirname, "/", entry->d_name)) == NULL || - ft_htset(path, entry->d_name, filepath, free) == NULL) - { - free(filepath); - closedir(dir); - return (NULL); - } + free(filepath); + return (-1); } - if (closedir(dir) == -1) - return (NULL); - return (path); + return (0); } /* @@ -74,8 +64,8 @@ t_path path_update(t_path path, char *path_var) if ((dirs = ft_split(path_var, ':')) == NULL) return (NULL); i = -1; - while (dirs[++i] != NULL) - if (st_path_dir_update(path, dirs[i]) == NULL) + while (dirs[++i] != NULL) // carefull with non existant dir error + if (utils_directory_iter(dirs[i], path, st_add_file) == -1) return (ft_split_destroy(dirs)); ft_split_destroy(dirs); return (path); -- cgit From 4aeba6d2f03706fa21281709a138a7d3ea9797dc Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 5 Apr 2020 15:04:23 +0200 Subject: Preprocessing (glob and iterpolation) draft (not tested) --- src/path.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/path.c') diff --git a/src/path.c b/src/path.c index c9f184c..d768d07 100644 --- a/src/path.c +++ b/src/path.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/27 15:51:01 by cacharle #+# #+# */ -/* Updated: 2020/04/03 13:53:01 by charles ### ########.fr */ +/* Updated: 2020/04/05 12:09:05 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,7 @@ */ #include "minishell.h" +#include "utils.h" /* ** \brief Number of buckets of a path hash table -- cgit