Archived
1
0

wip_parsing

This commit is contained in:
Maelys
2024-09-10 16:27:06 +02:00
commit c671539661
62 changed files with 1863 additions and 0 deletions

46
src/parsing/check_arg.c Normal file
View File

@ -0,0 +1,46 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_arg.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/04 21:33:35 by madumerg #+# #+# */
/* Updated: 2024/09/07 17:57:29 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../include/cub3d.h"
int check_err_arg(int ac, char **av)
{
int fd;
int rd;
char buf[10];
if (ac != 2)
return (err_mess(ERR_ARGS));
if (check_format_file(av[1]) == 0)
return (err_mess(ERR_TYPE));
fd = open(av[1], O_RDONLY);
if (fd == -1)
{
close(fd);
return (err_mess(EMPTY));
}
rd = read(fd, buf, 10);
close(fd);
return (rd);
}
int check_format_file(char *file)
{
int len;
len = ft_strlen(file) - 1;
if (file[len] == 'b' && file[len - 1] == 'u' && \
file[len - 2] == 'c' && file[len - 3] == '.')
return (1);
return (0);
}