Hello. How to find current executable's path (not ...
# kotlin-native
w
Hello. How to find current executable's path (not working path) on MacOS? I can't find
_NSGetExecutablePath()
function in K/N macos target.
l
You may need to add a def file for mach-o/dyld.h
w
Copy code
actual val executablePath: String = memScoped {
    val buff = allocArray<ByteVar>(pathBufferSize)
    val pid = getpid()
    val ret = proc_pidpath(pid, buff, pathBufferSize.toUInt())
    if(ret < 0) {
        perror("Error getting pidpath")
        return@memScoped ""
    }
       buff.toKStringFromUtf8()
}
I found this