-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtreat.c
57 lines (52 loc) · 1.52 KB
/
treat.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* treat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: amezioun <amezioun@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/13 23:29:05 by amezioun #+# #+# */
/* Updated: 2024/07/14 00:54:10 by amezioun ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
int camp(char *filename)
{
char *ext;
int i;
ext = ".ber";
i = ft_strlen(filename) - 4;
while (filename[i])
{
if (filename[i] != *ext)
return (-1);
ext++;
i++;
}
return (0);
}
void treat(char *filename, t_map *mlx)
{
int fd;
fd = open(filename, O_RDONLY);
if (fd == -1)
{
write(2, "Invalid map !\n", 14);
exit(1);
}
else
{
ft_store(filename, mlx);
player_check(mlx->map);
if (check_path(mlx->map) == 1)
{
ft_free(mlx->map, mlx->y);
write(2, "Error: the map provided does not have a valid path\n",
52);
exit(1);
}
ft_free(mlx->map, mlx->y);
ft_store(filename, mlx);
}
close(fd);
}