diff options
Diffstat (limited to 'src/ft_parse_map.c')
-rw-r--r-- | src/ft_parse_map.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index 3d19fdc..d3a90af 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -74,12 +74,14 @@ static int8_t return (ret); } -static void - ft_no_map_error(t_cub *clist) +void + ft_save_name(t_map *mlist, t_cub *clist) { - ft_dprintf(STDERR_FILENO, "Error\n"); - ft_dprintf(STDERR_FILENO, "\033[31;1mNo map\033[0m\n"); - ft_exit(FT_RET_NO_MAP, clist); + ft_memdel((void**)mlist->filename); + if (!(mlist->filename = + (char*)malloc((ft_strlen(map_path) + 1) * sizeof(char)))) + ft_error(FT_RET_ALLOC_ERR, FT_ERR_ALLOCATE, clist); + ft_sprintf(mlist->filename, map_path); } void @@ -90,9 +92,10 @@ void if (ft_check_ext(map_path, ".cub") < 0) ft_map_error(FT_ERR_NOT_A_CUB, clist); + ft_save_name(&clist->mlist, clist); fd = open(map_path, O_RDONLY); if (fd < 0) - ft_no_map_error(clist); + ft_error(FT_RET_NO_MAP, FT_ERR_NO_MAP, clist); ret = 1; while (ret != 12 && ret >= 0) ret = ft_parse_it(fd, clist); |