os: add getAppFilename() implementation for Haiku
This commit is contained in:
parent
9a9005622b
commit
8cc1c55620
1 changed files with 20 additions and 0 deletions
|
|
@ -1476,6 +1476,24 @@ when defined(macosx):
|
||||||
proc getExecPath2(c: cstring, size: var cuint32): bool {.
|
proc getExecPath2(c: cstring, size: var cuint32): bool {.
|
||||||
importc: "_NSGetExecutablePath", header: "<mach-o/dyld.h>".}
|
importc: "_NSGetExecutablePath", header: "<mach-o/dyld.h>".}
|
||||||
|
|
||||||
|
when defined(haiku):
|
||||||
|
const
|
||||||
|
PATH_MAX = 1024
|
||||||
|
B_FIND_PATH_IMAGE_PATH = 1000
|
||||||
|
|
||||||
|
proc find_path(codePointer: pointer, baseDirectory: cint, subPath: cstring,
|
||||||
|
pathBuffer: cstring, bufferSize: csize): int32
|
||||||
|
{.importc, header: "<FindDirectory.h>".}
|
||||||
|
|
||||||
|
proc getApplHaiku(): string =
|
||||||
|
result = newString(PATH_MAX)
|
||||||
|
|
||||||
|
if find_path(nil, B_FIND_PATH_IMAGE_PATH, nil, result, PATH_MAX) == 0:
|
||||||
|
let realLen = len(cstring(result))
|
||||||
|
setLen(result, realLen)
|
||||||
|
else:
|
||||||
|
result = ""
|
||||||
|
|
||||||
proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect].} =
|
proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect].} =
|
||||||
## Returns the filename of the application's executable.
|
## Returns the filename of the application's executable.
|
||||||
##
|
##
|
||||||
|
|
@ -1530,6 +1548,8 @@ proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect].} =
|
||||||
raiseOSError(OSErrorCode(-1), "POSIX command line not supported")
|
raiseOSError(OSErrorCode(-1), "POSIX command line not supported")
|
||||||
elif defined(freebsd) or defined(dragonfly):
|
elif defined(freebsd) or defined(dragonfly):
|
||||||
result = getApplFreebsd()
|
result = getApplFreebsd()
|
||||||
|
elif defined(haiku):
|
||||||
|
result = getApplHaiku()
|
||||||
# little heuristic that may work on other POSIX-like systems:
|
# little heuristic that may work on other POSIX-like systems:
|
||||||
if result.len == 0:
|
if result.len == 0:
|
||||||
result = getApplHeuristic()
|
result = getApplHeuristic()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue