mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
22 lines
400 B
C++
22 lines
400 B
C++
#include "precompiled.h"
|
|
|
|
#include "lib/sysdep/sysdep.h"
|
|
|
|
#define GNU_SOURCE
|
|
#include <dlfcn.h>
|
|
|
|
LibError sys_get_executable_name(char* n_path, size_t buf_size)
|
|
{
|
|
Dl_info dl_info;
|
|
|
|
memset(&dl_info, 0, sizeof(dl_info));
|
|
if (!dladdr((void *)sys_get_executable_name, &dl_info) ||
|
|
!dl_info.dli_fname )
|
|
{
|
|
return ERR::NO_SYS;
|
|
}
|
|
|
|
strncpy(n_path, dl_info.dli_fname, buf_size);
|
|
return INFO::OK;
|
|
}
|
|
|