#define _POSIX_C_SOURCE 200809L /* Isolated from raylib.h to avoid Rectangle/CloseWindow/ShowCursor conflicts with windows.h on Windows cross-compile targets. */ #ifdef _WIN32 # include # include #else # include # include #endif #include #include "platform.h" void chdirToExeDir(void) { char path[1024]; #ifdef _WIN32 DWORD len = GetModuleFileNameA(NULL, path, (DWORD)sizeof(path)); if (!len) return; char *last = strrchr(path, '\\'); if (!last) last = strrchr(path, '/'); if (last) { *last = '\0'; _chdir(path); } #else ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1); if (len <= 0) return; path[len] = '\0'; if (chdir(dirname(path)) != 0) { } #endif }