mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:27:34 +00:00
LibCore: Implement current_executable_path() on Haiku
This commit is contained in:
parent
ae34c35d64
commit
a1572555c2
1 changed files with 13 additions and 0 deletions
|
@ -63,6 +63,10 @@ extern "C" {
|
||||||
# include <LibCore/File.h>
|
# include <LibCore/File.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(AK_OS_HAIKU)
|
||||||
|
# include <image.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define HANDLE_SYSCALL_RETURN_VALUE(syscall_name, rc, success_value) \
|
#define HANDLE_SYSCALL_RETURN_VALUE(syscall_name, rc, success_value) \
|
||||||
if ((rc) < 0) { \
|
if ((rc) < 0) { \
|
||||||
return Error::from_syscall(syscall_name##sv, rc); \
|
return Error::from_syscall(syscall_name##sv, rc); \
|
||||||
|
@ -1809,6 +1813,15 @@ ErrorOr<String> current_executable_path()
|
||||||
auto ret = _NSGetExecutablePath(path, &size);
|
auto ret = _NSGetExecutablePath(path, &size);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return Error::from_errno(ENAMETOOLONG);
|
return Error::from_errno(ENAMETOOLONG);
|
||||||
|
#elif defined(AK_OS_HAIKU)
|
||||||
|
image_info info = {};
|
||||||
|
for (int32 cookie { 0 }; get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK && info.type != B_APP_IMAGE;)
|
||||||
|
;
|
||||||
|
if (info.type != B_APP_IMAGE)
|
||||||
|
return Error::from_string_view("current_executable_path() failed"sv);
|
||||||
|
if (sizeof(info.name) > sizeof(path))
|
||||||
|
return Error::from_errno(ENAMETOOLONG);
|
||||||
|
strlcpy(path, info.name, sizeof(path) - 1);
|
||||||
#elif defined(AK_OS_EMSCRIPTEN)
|
#elif defined(AK_OS_EMSCRIPTEN)
|
||||||
return Error::from_string_view("current_executable_path() unknown on this platform"sv);
|
return Error::from_string_view("current_executable_path() unknown on this platform"sv);
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue