0ad/source/lib/sysdep/os/linux/linux.cpp
janwas a3696c0b91 premake: detect processor architecture from script
lib/sysdep: clean up by moving OS and cpu-arch folders into "os" and
"arch" folders

This was SVN commit r6162.
2008-06-30 17:34:18 +00:00

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;
}