diff --git a/src/common/init.c b/src/common/init.c index 2be0bea..57ec243 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -3,6 +3,7 @@ #include #include #include +#include #include void dragonblocks_init(int argc) @@ -11,8 +12,16 @@ void dragonblocks_init(int argc) pthread_setname_np(pthread_self(), "main"); #endif // __GLIBC__ + // stat() does not properly handle trailing slashes on dirs on MinGW in some cases + // strip trailing slashes + size_t len = strlen(ASSET_PATH); + char stat_path[len+1]; + strcpy(stat_path, ASSET_PATH); + while (len > 0 && stat_path[len-1] == '/') + stat_path[--len] = '\0'; + struct stat sb; - if (stat(ASSET_PATH, &sb) != 0 || !S_ISDIR(sb.st_mode)) { + if (stat(stat_path, &sb) != 0 || !S_ISDIR(sb.st_mode)) { fprintf(stderr, "[error] asset directory not found at %s, " "invoke game from correct path\n", ASSET_PATH); exit(EXIT_FAILURE);