소스 검색

chore: GetApplicationDirectory definition for FreeBSD (#4318)

pull/4325/head
base 7 달 전
committed by GitHub
부모
커밋
d02fcc5262
No known key found for this signature in database GPG 키 ID: B5690EEEBB952194
1개의 변경된 파일26개의 추가작업 그리고 0개의 파일을 삭제
  1. +26
    -0
      src/rcore.c

+ 26
- 0
src/rcore.c 파일 보기

@ -165,6 +165,10 @@ unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod);
unsigned int __stdcall timeEndPeriod(unsigned int uPeriod); unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
#elif defined(__linux__) #elif defined(__linux__)
#include <unistd.h> #include <unistd.h>
#elif defined(__FreeBSD__)
#include <sys/types.h>
#include <sys/sysctl.h>
#include <unistd.h>
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include <sys/syslimits.h> #include <sys/syslimits.h>
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
@ -2161,6 +2165,28 @@ const char *GetApplicationDirectory(void)
appDir[0] = '.'; appDir[0] = '.';
appDir[1] = '/'; appDir[1] = '/';
} }
#elif defined(__FreeBSD__)
size_t size = sizeof(appDir);
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
if (sysctl(mib, 4, appDir, &size, NULL, 0) == 0)
{
int len = strlen(appDir);
for (int i = len; i >= 0; --i)
{
if (appDir[i] == '/')
{
appDir[i + 1] = '\0';
break;
}
}
}
else
{
appDir[0] = '.';
appDir[1] = '/';
}
#endif #endif
return appDir; return appDir;

불러오는 중...
취소
저장