-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_name.c
32 lines (29 loc) · 1.28 KB
/
map_name.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
/* ************************************************************************** */
/* */
/* :::::::: */
/* map_name.c :+: :+: */
/* +:+ */
/* By: cschuijt <[email protected]> +#+ */
/* +#+ */
/* Created: 2022/12/22 22:59:08 by cschuijt #+# #+# */
/* Updated: 2022/12/22 22:59:08 by cschuijt ######## odam.nl */
/* */
/* ************************************************************************** */
#include "so_long.h"
void fill_in_map_name(t_map *map, char *path)
{
char **split_path;
char *file_name;
size_t index;
split_path = ft_split(path, '/');
if (!split_path)
exit_perror("malloc error");
index = 0;
while (split_path[index])
index++;
file_name = ft_strdup(split_path[index - 1]);
if (!file_name)
exit_perror("malloc error");
free_array((void **)split_path);
map->map_name = file_name;
}