From e21739dd8caf7d6a9aefe68c37eddb6406bcb810 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Tue, 25 Apr 2023 20:16:39 +0100 Subject: [PATCH] std.fs: selfExePath haiku using constants instead --- lib/std/c/haiku.zig | 11 +++++++++-- lib/std/fs.zig | 3 +-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/std/c/haiku.zig b/lib/std/c/haiku.zig index 9b693a59c2..b0fcb710af 100644 --- a/lib/std/c/haiku.zig +++ b/lib/std/c/haiku.zig @@ -11,9 +11,9 @@ extern "c" fn _errnop() *c_int; pub const _errno = _errnop; -pub extern "c" fn find_directory(which: c_int, volume: i32, createIt: bool, path_ptr: [*]u8, length: i32) status_t; +pub extern "c" fn find_directory(which: directory_which, volume: i32, createIt: bool, path_ptr: [*]u8, length: i32) status_t; -pub extern "c" fn find_path(codePointer: *const u8, baseDirectory: c_int, subPath: [*:0]const u8, pathBuffer: [*:0]u8, bufferSize: usize) status_t; +pub extern "c" fn find_path(codePointer: *const u8, baseDirectory: path_base_directory, subPath: [*:0]const u8, pathBuffer: [*:0]u8, bufferSize: usize) status_t; pub extern "c" fn find_thread(thread_name: ?*anyopaque) i32; @@ -1024,6 +1024,13 @@ pub const directory_which = enum(c_int) { _, }; +// TODO fill out if needed +pub const path_base_directory = enum(c_int) { + B_FIND_PATH_IMAGE_PATH = 1000, +}; + +pub const B_APP_IMAGE_SYMBOL = null; + pub const cc_t = u8; pub const speed_t = u8; pub const tcflag_t = u32; diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 9f64387bd8..7327a3a913 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -2999,8 +2999,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { .haiku => { // The only possible issue when looking for the self image path is // when the buffer is too short. - // TODO replace with proper constants - if (os.find_path(null, 1000, null, out_buffer.ptr, out_buffer.len) != 0) + if (os.find_path(os.B_APP_IMAGE_SYMBOL, os.path_base_directory.B_FIND_IMAGE_PATH, null, out_buffer.ptr, out_buffer.len) != 0) return error.Overflow; return mem.sliceTo(out_buffer, 0); },