MCPcopy Create free account
hub / github.com/NetHack/NetHack / get_executable_path

Function get_executable_path

sys/windows/windsys.c:827–850  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

825}
826
827char *
828get_executable_path(void)
829{
830#ifdef UNICODE
831 {
832 TCHAR wbuf[BUFSZ];
833 GetModuleFileName((HANDLE) 0, wbuf, BUFSZ);
834 WideCharToMultiByte(CP_ACP, 0, wbuf, -1, path_buffer,
835 sizeof(path_buffer), NULL, NULL);
836 }
837#else
838 DWORD length = GetModuleFileName((HANDLE) 0, path_buffer, MAX_PATH);
839 if (length == ERROR_INSUFFICIENT_BUFFER)
840 error("Unable to get module name");
841 path_buffer[length] = '\0';
842#endif
843
844 char *separator = strrchr(path_buffer, PATH_SEPARATOR);
845 if (separator)
846 *separator = '\0';
847
848 path_buffer_set = TRUE;
849 return path_buffer;
850}
851
852char *
853windows_exepath(void)

Callers 1

windsys.cFile · 0.85

Calls 2

strrchrFunction · 0.85
errorFunction · 0.50

Tested by

no test coverage detected