diff --git a/core/os/os2/path_darwin.odin b/core/os/os2/path_darwin.odin index 2e7bbc7b9..65aaf1e95 100644 --- a/core/os/os2/path_darwin.odin +++ b/core/os/os2/path_darwin.odin @@ -6,26 +6,12 @@ import "core:sys/darwin" import "core:sys/posix" _get_executable_path :: proc(allocator: runtime.Allocator) -> (path: string, err: Error) { - size: u32 - - ret := darwin._NSGetExecutablePath(nil, &size) - assert(ret == -1) - assert(size > 0) - - TEMP_ALLOCATOR_GUARD() - - buf := make([]byte, size, temp_allocator()) or_return - assert(u32(len(buf)) == size) - - ret = darwin._NSGetExecutablePath(raw_data(buf), &size) - assert(ret == 0) - - real := posix.realpath(cstring(raw_data(buf))) - if real == nil { - err = _get_platform_error() - return + buffer: [darwin.PIDPATHINFO_MAXSIZE]byte = --- + ret := darwin.proc_pidpath(posix.getpid(), raw_data(buffer[:]), len(buffer)) + if ret > 0 { + return clone_string(string(buffer[:ret]), allocator) } - defer posix.free(real) - return clone_string(string(real), allocator) + err = _get_platform_error() + return } diff --git a/core/sys/darwin/dyld.odin b/core/sys/darwin/dyld.odin deleted file mode 100644 index 0a6a2cfa6..000000000 --- a/core/sys/darwin/dyld.odin +++ /dev/null @@ -1,7 +0,0 @@ -package darwin - -foreign import system "system:System.framework" - -foreign system { - _NSGetExecutablePath :: proc(buf: [^]byte, bufsize: ^u32) -> i32 --- -}