os/os2: add get_executable_path and get_executable_directory

This commit is contained in:
Laytan Laats
2025-01-21 18:54:45 +01:00
parent 223970671f
commit b673642412
10 changed files with 234 additions and 3 deletions
+11 -2
View File
@@ -10,8 +10,12 @@ _error_string :: proc(errno: i32) -> string {
return string(posix.strerror(posix.Errno(errno)))
}
_get_platform_error :: proc() -> Error {
#partial switch errno := posix.errno(); errno {
_get_platform_error_from_errno :: proc() -> Error {
return _get_platform_error_existing(posix.errno())
}
_get_platform_error_existing :: proc(errno: posix.Errno) -> Error {
#partial switch errno {
case .EPERM:
return .Permission_Denied
case .EEXIST:
@@ -32,3 +36,8 @@ _get_platform_error :: proc() -> Error {
return Platform_Error(errno)
}
}
_get_platform_error :: proc{
_get_platform_error_existing,
_get_platform_error_from_errno,
}