-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_open_files.c
More file actions
34 lines (32 loc) · 1.37 KB
/
ft_open_files.c
File metadata and controls
34 lines (32 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_open_files.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mrhyhorn <mrhyhorn@student.21-school.ru +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/06 18:28:56 by mrhyhorn #+# #+# */
/* Updated: 2022/03/08 13:05:05 by mrhyhorn ### ########.fr */
/* */
/* ************************************************************************** */
#include "pipex.h"
void ft_open_files(char **argv, t_data *data)
{
data->infile_fd = open(argv[1], O_RDONLY);
if (data->infile_fd == -1)
{
ft_putstr_fd(strerror(errno), 2);
ft_putstr_fd(" : ", 2);
ft_putstr_fd(argv[1], 2);
ft_putstr_fd("\n", 2);
}
data->outfile_fd = open(argv[4], O_WRONLY | O_TRUNC | O_CREAT, 0666);
if (data->outfile_fd == -1)
{
ft_putstr_fd(strerror(errno), 2);
ft_putstr_fd(" : ", 2);
ft_putstr_fd(argv[4], 2);
ft_putstr_fd("\n", 2);
exit(EXIT_FAILURE);
}
}