blob: 90ee38dca6bab5ea1e840e6c2520a767bd4e6f2b (
plain)
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_read_file.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/22 10:32:47 by cacharle #+# #+# */
/* Updated: 2020/02/22 10:35:07 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft_io.h"
char *ft_read_file(char *filename)
{
int fd;
char *file;
if ((fd = open(filename, O_RDONLY)) < 0 || fd > OPEN_MAX)
return (NULL);
if ((file = ft_read_fd(fd)) == NULL)
{
free(file);
return (NULL);
}
if (close(fd) < 0)
{
free(file);
return (NULL);
}
return (file);
}
|