path_darwin.odin 415 B

1234567891011121314151617
  1. package os2
  2. import "base:runtime"
  3. import "core:sys/darwin"
  4. import "core:sys/posix"
  5. _get_executable_path :: proc(allocator: runtime.Allocator) -> (path: string, err: Error) {
  6. buffer: [darwin.PIDPATHINFO_MAXSIZE]byte = ---
  7. ret := darwin.proc_pidpath(posix.getpid(), raw_data(buffer[:]), len(buffer))
  8. if ret > 0 {
  9. return clone_string(string(buffer[:ret]), allocator)
  10. }
  11. err = _get_platform_error()
  12. return
  13. }