From 6547c721f559237a0507be1c8aec2ac185c3aa2f Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Sat, 25 Mar 2017 01:54:17 +0100 Subject: [PATCH] rectif redir --- 42sh/libft/includes/error.h | 2 +- 42sh/libft/src/error/error.c | 2 +- 42sh/libft/src/sys/open_access.c | 4 ++-- 42sh/src/exec/redirect_dgreat.c | 6 +++--- 42sh/src/exec/redirect_less.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/42sh/libft/includes/error.h b/42sh/libft/includes/error.h index 0f587158..5ea206a9 100644 --- a/42sh/libft/includes/error.h +++ b/42sh/libft/includes/error.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 15:34:21 by jhalford #+# #+# */ -/* Updated: 2017/03/25 01:34:24 by jhalford ### ########.fr */ +/* Updated: 2017/03/25 01:53:21 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft/src/error/error.c b/42sh/libft/src/error/error.c index 971d22f9..6900c094 100644 --- a/42sh/libft/src/error/error.c +++ b/42sh/libft/src/error/error.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 16:47:00 by jhalford #+# #+# */ -/* Updated: 2017/03/25 01:22:37 by jhalford ### ########.fr */ +/* Updated: 2017/03/25 01:53:25 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft/src/sys/open_access.c b/42sh/libft/src/sys/open_access.c index 0f978306..90790a31 100644 --- a/42sh/libft/src/sys/open_access.c +++ b/42sh/libft/src/sys/open_access.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/25 01:10:56 by jhalford #+# #+# */ -/* Updated: 2017/03/25 01:50:00 by jhalford ### ########.fr */ +/* Updated: 2017/03/25 01:53:59 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,7 +28,7 @@ int open_access(char *file, t_flag a_flag, t_flag o_flag, t_flag o_perm) return (-ERR_SET(E_SYS_NOFILE, file)); if (is_directory(file)) return (-ERR_SET(E_SYS_ISDIR, file)); - if (access(file, a_flag)) + if (access(file, a_flag) != 0) return (-ERR_SET(E_SYS_NOPERM, file)); if ((fd = open(file, o_flag, o_perm)) < 0) { diff --git a/42sh/src/exec/redirect_dgreat.c b/42sh/src/exec/redirect_dgreat.c index 97200090..3e448fd8 100644 --- a/42sh/src/exec/redirect_dgreat.c +++ b/42sh/src/exec/redirect_dgreat.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:07:37 by jhalford #+# #+# */ -/* Updated: 2017/03/25 01:49:36 by jhalford ### ########.fr */ +/* Updated: 2017/03/25 01:54:05 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,8 +18,8 @@ int redirect_dgreat(t_redir *redir) int fdnew; fdnew = redir->n; - if ((fdold = open(redir->word, R_OK, - O_WRONLY | O_CREAT | O_APPEND, 0644)) != 0) + if ((fdold = open_access(redir->word, R_OK, + O_WRONLY | O_CREAT | O_APPEND, 0644)) < 0) return (ft_perror(NULL)); dup2(fdold, fdnew); return (0); diff --git a/42sh/src/exec/redirect_less.c b/42sh/src/exec/redirect_less.c index 08dd067b..d38e079b 100644 --- a/42sh/src/exec/redirect_less.c +++ b/42sh/src/exec/redirect_less.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:09:53 by jhalford #+# #+# */ -/* Updated: 2017/03/25 01:49:52 by jhalford ### ########.fr */ +/* Updated: 2017/03/25 01:52:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */