Repository navigation
Expand file tree
/
Copy pathmain.c
More file actions
51 lines (47 loc) · 1.44 KB
/
Copy pathmain.c
File metadata and controls
51 lines (47 loc) · 1.44 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adelaloy <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/26 15:36:21 by adelaloy #+# #+# */
/* Updated: 2023/06/26 15:53:29 by adelaloy ### ########.fr */
/* */
/* ************************************************************************** */
#include "lib.h"
int get_fd(char *path)
{
int fd;
fd = open(path, O_RDONLY);
if (!ft_check_open(fd) || !ft_check_read(fd))
ft_puterr("map error\n");
return (fd);
}
int main(int argc, char **argv)
{
int i;
int fd;
size_t file_size;
if (argc != 1)
{
i = 1;
while (i < argc)
{
fd = get_fd(argv[i]);
if (fd != -1)
{
file_size = ft_get_fsize(fd);
fd = get_fd(argv[i]);
if (fd != -1)
map_solve(ft_get_file(fd, file_size));
}
if (argc > 2)
ft_putchar('\n');
i++;
}
}
else
map_solve(ft_get_stdin_string());
return (0);
}