check dir

This commit is contained in:
Elisee ADJIGUIDI 2022-06-15 17:29:48 +02:00
parent 72ab74692c
commit c496582e57
2 changed files with 17 additions and 2 deletions

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/13 16:30:59 by apommier #+# #+# */
/* Updated: 2022/06/15 17:02:52 by apommier ### ########.fr */
/* Updated: 2022/06/15 17:28:47 by sadjigui ### ########.fr */
/* */
/* ************************************************************************** */
@ -125,5 +125,6 @@ int quit_game(t_data *img);
void ft_error(char *error_msg);
void print_player(player player, t_data *img);
void print_map(map_info map, t_data *img);
void check_dir(char *path, t_data *img);
#endif

View File

@ -6,12 +6,25 @@
/* By: sadjigui <sadjigui@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/10 17:54:25 by sadjigui #+# #+# */
/* Updated: 2022/06/15 16:46:36 by sadjigui ### ########.fr */
/* Updated: 2022/06/15 17:24:27 by sadjigui ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../includes/Cub3D.h"
void check_dir(char *path, t_data *img)
{
int fd;
fd = open(path, O_DIRECTORY);
if (fd >= 0)
{
close(fd);
ft_exit("Error\nTexture path is a directory\n", img);
}
close(fd);
}
void ft_exit(char *str, t_data *img)
{
ft_putstr_fd(str, 2);
@ -286,6 +299,7 @@ char **isafile(char **av, t_data *img)
char *tmp;
char **split;
check_dir(av[1], img);
img->err = 0;
fd = open(av[1], O_RDONLY);
img->to_be_free.fd = fd;