diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-23 15:20:42 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-23 15:20:42 +0200 |
commit | e3eab8d0d505023977e59940737a7ca42e098a08 (patch) | |
tree | 9c9bb39e35e3deb4990015b22ca65ae7b9004b8a /src/ft_p_lcom.c | |
parent | The worst is that it actually works (diff) | |
download | 42-minishell-e3eab8d0d505023977e59940737a7ca42e098a08.tar.gz 42-minishell-e3eab8d0d505023977e59940737a7ca42e098a08.tar.bz2 42-minishell-e3eab8d0d505023977e59940737a7ca42e098a08.tar.xz 42-minishell-e3eab8d0d505023977e59940737a7ca42e098a08.tar.zst 42-minishell-e3eab8d0d505023977e59940737a7ca42e098a08.zip |
Ok it's fine
Diffstat (limited to 'src/ft_p_lcom.c')
-rw-r--r-- | src/ft_p_lcom.c | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/src/ft_p_lcom.c b/src/ft_p_lcom.c index 45fcf17..b5fdc85 100644 --- a/src/ft_p_lcom.c +++ b/src/ft_p_lcom.c @@ -20,35 +20,6 @@ #include "ft_s_struct.h" static void - ft_check_redir_file(t_lcom **link) -{ - int32_t fd; - - fd = 0; - if ((*link)->redir == -1 && (fd = open((*link)->rdrpath, O_RDONLY)) == -1) - { - /* TODO: better error handling | DON'T EXEC CMD | retval 1 */ - if (errno == ENOENT) - ft_dprintf(STDERR_FILENO, - "minishell: %s: No such file or directory\n", (*link)->rdrpath); - else if (errno == EACCES) - ft_dprintf(STDERR_FILENO, - "minishell: %s: Permission denied\n", (*link)->rdrpath); - return ; - } - else if ((*link)->redir == 1 - && (fd = open((*link)->rdrpath, O_CREAT | O_WRONLY, 0644)) == -1) - { - /* TODO: same as above */ - if (errno == EACCES) - ft_dprintf(STDERR_FILENO, - "minishell: %s: Permission denied\n", (*link)->rdrpath); - } - /* TODO: >> redir file check */ - close(fd); -} - -static void ft_rdr_err_check(char *ptr, t_lcom **link) { @@ -59,7 +30,7 @@ static void else if ((*link)->redir == 1 && ft_ischarset("<", *(ptr + 1))) { } - else if ((*link)->redir == 1 && ft_ischarset("<>", *(ptr + 1))) + else if ((*link)->redir == 2 && ft_ischarset("<>", *(ptr + 1))) { } } @@ -87,6 +58,7 @@ static int8_t ptr++; } *p_rdrpath = '\0'; + ft_printf("[%s]\n", (*link)->rdrpath); return (0); } @@ -118,8 +90,6 @@ int8_t ft_rdr_err_check(ptr, link); if (ft_get_rdrpath(ptr, link) != 0) return (-1); - /* TODO: don't check files here, check at run-time */ - ft_check_redir_file(link); } return (0); } |