-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_get_file_content.c
33 lines (30 loc) · 1.38 KB
/
ft_get_file_content.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_get_file_content.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lduplain <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/03/22 18:59:55 by lduplain #+# #+# */
/* Updated: 2021/04/01 11:54:57 by lduplain ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char **ft_get_file_content(char *path)
{
char **file_content;
t_file *file;
size_t line_index;
file_content = ft_create_file_content(path);
if (file_content == NULL)
return (NULL);
file = ft_open_file(path, O_RDONLY);
if (file == NULL)
return (ft_destroy_file_content(&file_content));
line_index = 0;
file_content = ft_fill_file_content(file_content, file);
ft_close_file(file);
if (file_content == NULL)
return (ft_destroy_file_content(&file_content));
return (file_content);
}