Fix build on FreeBSD

This commit is contained in:
porsolic 2023-02-06 19:27:09 +01:00 committed by Marek Kraus
parent 3fff531334
commit a67ab9d218
2 changed files with 8 additions and 3 deletions

View File

@ -35,6 +35,11 @@ ssize_t util_get_binary_folder(char* buffer, uint32_t buffer_size) {
#elif defined(__APPLE__)
util_get_executable_path(buffer, buffer_size);
char* pos = strrchr(buffer, '/');
#elif __FreeBSD__
if (readlink("/proc/curproc/file", buffer, buffer_size) <= 0) {
return -1;
}
char* pos = strrchr(buffer, '/');
#else
if (GetModuleFileName(NULL, buffer, buffer_size) <= 0) {
return -1;

View File

@ -4,9 +4,7 @@
#include <stdint.h>
#ifdef __linux__
#include <unistd.h>
#elif defined(_MSC_VER)
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#include <windows.h>
@ -15,6 +13,8 @@ typedef SSIZE_T ssize_t;
#include <sys/syslimits.h>
#include <assert.h>
#include <sys/types.h>
#else
#include <unistd.h>
#endif
ssize_t util_get_binary_folder(char* buffer, uint32_t buffer_size);