Added filetype checking

This commit is contained in:
Theo Champion 2025-06-04 19:16:59 +02:00
parent 8f99d23431
commit 935370ac63
5 changed files with 58 additions and 27 deletions

View file

@ -12,7 +12,7 @@
#include "../includes/libft.h"
#include "../includes/mlx.h"
//#include "../includes/filecheck.h"
#include "../includes/maputils.h"
#include <stdbool.h>
#include <unistd.h>
#include <fcntl.h>
@ -26,12 +26,6 @@ typedef struct s_mlx_data
int endian;
} t_mlx_data;
typedef struct s_mapdata
{
char *filename;
bool isvalid;
char error[1024];
} t_mapdata;
void my_mlx_pixel_put(t_mlx_data *data, int x, int y, int color)
{
@ -41,25 +35,6 @@ void my_mlx_pixel_put(t_mlx_data *data, int x, int y, int color)
*(unsigned int*)dst = color;
}
bool check_filename(char *file)
{
(void)file;
return (false);
}
bool check_cubfile(char *file, t_mapdata *map)
{
int fd;
fd = open(file, O_RDONLY);
if (fd < 0)
return (ft_strlcpy(map->error, "Can't open file", 16), false);
if (!check_filename(file))
return (ft_strlcpy(map->error, "File is not a .cub file", 25), false);
close(fd);
return (true);
}
int main(int argc, char **argv)
{
void *mlx;