rectif redir

This commit is contained in:
Jack Halford 2017-03-25 01:54:17 +01:00
parent a5cb86d0a8
commit 6547c721f5
5 changed files with 8 additions and 8 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 15:34:21 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 16:47:00 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/25 01:10:56 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)); return (-ERR_SET(E_SYS_NOFILE, file));
if (is_directory(file)) if (is_directory(file))
return (-ERR_SET(E_SYS_ISDIR, 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)); return (-ERR_SET(E_SYS_NOPERM, file));
if ((fd = open(file, o_flag, o_perm)) < 0) if ((fd = open(file, o_flag, o_perm)) < 0)
{ {

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:07:37 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; int fdnew;
fdnew = redir->n; fdnew = redir->n;
if ((fdold = open(redir->word, R_OK, if ((fdold = open_access(redir->word, R_OK,
O_WRONLY | O_CREAT | O_APPEND, 0644)) != 0) O_WRONLY | O_CREAT | O_APPEND, 0644)) < 0)
return (ft_perror(NULL)); return (ft_perror(NULL));
dup2(fdold, fdnew); dup2(fdold, fdnew);
return (0); return (0);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:09:53 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */