libobs/util: FreeBSD/Dragonfly exec path support
Add support for FreeBSD and Dragonfly in os_get_executable_path_ptr(). This is required to obtain the path of the running executable image correctly. Fixes https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245299 Fixes https://github.com/obsproject/obs-studio/issues/2622master
parent
47058d9b69
commit
ab2743dd23
|
@ -275,7 +275,20 @@ char *os_get_program_data_path_ptr(const char *name)
|
|||
char *os_get_executable_path_ptr(const char *name)
|
||||
{
|
||||
char exe[PATH_MAX];
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
int sysctlname[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
|
||||
size_t pathlen = PATH_MAX;
|
||||
ssize_t count;
|
||||
if (sysctl(sysctlname, nitems(sysctlname), exe, &pathlen, NULL, 0) ==
|
||||
-1) {
|
||||
blog(LOG_ERROR, "sysctl(KERN_PROC_PATHNAME) failed, errno %d",
|
||||
errno);
|
||||
return NULL;
|
||||
}
|
||||
count = pathlen;
|
||||
#else
|
||||
ssize_t count = readlink("/proc/self/exe", exe, PATH_MAX);
|
||||
#endif
|
||||
const char *path_out = NULL;
|
||||
struct dstr path;
|
||||
|
||||
|
|
Loading…
Reference in New Issue