authorgravatar for devnexen@gmail.comDavid Carlier <devnexen@gmail.com> 2023-04-25 20:16:39+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-05-09 14:24:20+03:00
loge21739dd8caf7d6a9aefe68c37eddb6406bcb810
treeb5a19dc6a787fdd0fbfbed1aeccc7a494b7cb3b7
parente8f76b452bf86481069c2eeeb02d46161ea79a08

std.fs: selfExePath haiku using constants instead


2 files changed, 10 insertions(+), 4 deletions(-)

lib/std/c/haiku.zig+9-2
......@@ -11,9 +11,9 @@ extern "c" fn _errnop() *c_int;
1111
1212pub const _errno = _errnop;
1313
14pub extern "c" fn find_directory(which: c_int, volume: i32, createIt: bool, path_ptr: [*]u8, length: i32) status_t;
14pub extern "c" fn find_directory(which: directory_which, volume: i32, createIt: bool, path_ptr: [*]u8, length: i32) status_t;
1515
16pub extern "c" fn find_path(codePointer: *const u8, baseDirectory: c_int, subPath: [*:0]const u8, pathBuffer: [*:0]u8, bufferSize: usize) status_t;
16pub extern "c" fn find_path(codePointer: *const u8, baseDirectory: path_base_directory, subPath: [*:0]const u8, pathBuffer: [*:0]u8, bufferSize: usize) status_t;
1717
1818pub extern "c" fn find_thread(thread_name: ?*anyopaque) i32;
1919
......@@ -1024,6 +1024,13 @@ pub const directory_which = enum(c_int) {
10241024 _,
10251025};
10261026
1027// TODO fill out if needed
1028pub const path_base_directory = enum(c_int) {
1029 B_FIND_PATH_IMAGE_PATH = 1000,
1030};
1031
1032pub const B_APP_IMAGE_SYMBOL = null;
1033
10271034pub const cc_t = u8;
10281035pub const speed_t = u8;
10291036pub const tcflag_t = u32;
lib/std/fs.zig+1-2
......@@ -2999,8 +2999,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
29992999 .haiku => {
30003000 // The only possible issue when looking for the self image path is
30013001 // when the buffer is too short.
3002 // TODO replace with proper constants
3003 if (os.find_path(null, 1000, null, out_buffer.ptr, out_buffer.len) != 0)
3002 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)
30043003 return error.Overflow;
30053004 return mem.sliceTo(out_buffer, 0);
30063005 },