os2: improve absolute/full path handling for posix

This commit is contained in:
Laytan Laats
2024-08-14 01:45:23 +02:00
parent a73677d21a
commit b07d0b38b1
10 changed files with 137 additions and 26 deletions
+18
View File
@@ -0,0 +1,18 @@
//+private
package os2
import "base:runtime"
import "core:sys/posix"
_posix_absolute_path :: proc(fd: posix.FD, name: string, allocator: runtime.Allocator) -> (path: cstring, err: Error) {
F_GETPATH :: 50
buf: [posix.PATH_MAX]byte
if posix.fcntl(fd, posix.FCNTL_Cmd(F_GETPATH), &buf) != 0 {
err = _get_platform_error()
return
}
return clone_to_cstring(string(cstring(&buf[0])), allocator)
}