| 4897 | } |
| 4898 | |
| 4899 | static string _find_executable_path() |
| 4900 | { |
| 4901 | // A lot of OSes give ways to find the location of the running app's |
| 4902 | // binary executable. This is useful, because argv[0] can be relative |
| 4903 | // when we really need an absolute path in order to locate the game's |
| 4904 | // resources. |
| 4905 | #if defined (TARGET_OS_WINDOWS) |
| 4906 | wchar_t tempPath[MAX_PATH]; |
| 4907 | if (GetModuleFileNameW(nullptr, tempPath, MAX_PATH)) |
| 4908 | return utf16_to_8(tempPath); |
| 4909 | else |
| 4910 | return ""; |
| 4911 | #elif defined (UNIX) |
| 4912 | char tempPath[2048]; |
| 4913 | const ssize_t rsize = |
| 4914 | readlink("/proc/self/exe", tempPath, sizeof(tempPath) - 1); |
| 4915 | if (rsize > 0) |
| 4916 | { |
| 4917 | tempPath[rsize] = 0; |
| 4918 | return mb_to_utf8(tempPath); |
| 4919 | } |
| 4920 | return ""; |
| 4921 | #elif defined (TARGET_OS_MACOSX) |
| 4922 | return mb_to_utf8(NXArgv[0]); |
| 4923 | #else |
| 4924 | // We don't know how to find the executable's path on this OS. |
| 4925 | return ""; |
| 4926 | #endif |
| 4927 | } |
| 4928 | |
| 4929 | static void _print_version() |
| 4930 | { |
no test coverage detected