-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_source.c
More file actions
executable file
·33 lines (30 loc) · 1.2 KB
/
ft_source.c
File metadata and controls
executable file
·33 lines (30 loc) · 1.2 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* source.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cfavero <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/28 15:13:48 by cfavero #+# #+# */
/* Updated: 2017/12/20 12:48:43 by jszabo ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
char *ft_source(char *file)
{
int fd;
int size;
char *str;
if (!file)
return (0);
if (!(str = (char*)malloc(sizeof(*str) * (BUF_SIZE + 1))))
return (0);
if ((fd = open(file, O_RDONLY)) != -1)
{
size = read(fd, str, BUF_SIZE);
str[size] = '\0';
}
if (close(fd) == -1)
return (0);
return (str);
}