diff options
| -rwxr-xr-x | src/main.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -3,7 +3,9 @@ #include <SDL2/SDL_ttf.h> #include <SDL2/SDL_video.h> #include <stdio.h> +#include <stdlib.h> #include <stdbool.h> +#include <sys/stat.h> #include <time.h> #include <pthread.h> #include <SDL2/SDL.h> @@ -17,6 +19,30 @@ bool running=true; #define PROJECT_NAME "dacctal fish" +static int file_exists(const char *path) { + struct stat st; + return stat(path, &st) == 0; +} + +static void check_assets(void) { + int missing = 0; + if (!file_exists(fontfile)) { + SDL_LogWarn(0, "Missing: %s", fontfile); + missing++; + } + if (!file_exists(fishimg)) { + SDL_LogWarn(0, "Missing: %s", fishimg); + missing++; + } + if (!file_exists("patreons.txt")) { + SDL_LogWarn(0, "Missing: patreons.txt"); + missing++; + } + if (missing > 0) { + exit(EXIT_FAILURE); + } +} + int main(int argc, char *argv[]) { if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) @@ -26,6 +52,8 @@ int main(int argc, char *argv[]) SDL_Log("SDL fails to initialize ttf! %s\n", SDL_GetError()); } + check_assets(); + int startw=1920; int starth=1080; |
