diff --git a/ScuffedMinecraft/src/Application.cpp b/ScuffedMinecraft/src/Application.cpp index e8fbf25..4324888 100644 --- a/ScuffedMinecraft/src/Application.cpp +++ b/ScuffedMinecraft/src/Application.cpp @@ -4,6 +4,9 @@ #ifdef LINUX #include +#include +#include +#include #endif #include @@ -73,9 +76,22 @@ int main (int argc, char *argv[]) { for (size_t i = resolved_length; i > 0; i--) { if (resolved_path[i] == '/' && resolved_path[i+1] != 0) { resolved_path[i+1] = 0; + resolved_length = i; break; } } + + char* assets_path = (char *)malloc(resolved_length + strlen("assets") + 2); + strcpy(assets_path, resolved_path); + strcpy(assets_path + resolved_length + 1, "assets"); + struct stat path_stat; + if(stat(assets_path, &path_stat) == -1 || !S_ISDIR(path_stat.st_mode)) { + printf("%s: Asset directory not found\n", argv[0]); + exit(1); + } + + free(assets_path); + chdir(resolved_path); free(resolved_path); #endif