-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_open_file.c
executable file
·34 lines (31 loc) · 1.24 KB
/
ft_open_file.c
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_file.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lduplain <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/10 12:23:00 by lduplain #+# #+# */
/* Updated: 2021/03/22 15:36:53 by lduplain ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_file *ft_open_file(const char *path, int open_flag)
{
t_file *file;
int fd;
fd = open(path, open_flag);
if (fd == -1)
return (NULL);
file = ft_calloc(1, sizeof(t_file));
if (!file)
{
close(fd);
return (NULL);
}
file->c_fd = fd;
file->c_file_path = ft_strdup(path, FALSE);
file->readed_line = 0;
file->p_backup = 0;
return (file);
}