authorgravatar for devnexen@gmail.comDavid Carlier <devnexen@gmail.com> 2023-04-24 20:35:51+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-04-24 22:41:44+03:00
log7439eb5e99ba98bbdb2a0d0d71535e57d13f3c6e
tree34aff3dc6b2874a9cc616d9d7e84d6db3eb5210d
parentdc9472964325743e3f9e7f3cedfb942b5f44ad14

std.os: selfExePath implementation for haiku


1 files changed, 10 insertions(+), 1 deletions(-)

lib/std/fs.zig+10-1
...@@ -2913,6 +2913,7 @@ pub const OpenSelfExeError = error{...@@ -2913,6 +2913,7 @@ pub const OpenSelfExeError = error{
2913 /// On Windows, file paths cannot contain these characters:2913 /// On Windows, file paths cannot contain these characters:
2914 /// '/', '*', '?', '"', '<', '>', '|'2914 /// '/', '*', '?', '"', '<', '>', '|'
2915 BadPathName,2915 BadPathName,
2916 Overflow,
2916 Unexpected,2917 Unexpected,
2917} || os.OpenError || SelfExePathError || os.FlockError;2918} || os.OpenError || SelfExePathError || os.FlockError;
29182919
...@@ -2991,7 +2992,15 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {...@@ -2991,7 +2992,15 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
2991 // TODO could this slice from 0 to out_len instead?2992 // TODO could this slice from 0 to out_len instead?
2992 return mem.sliceTo(out_buffer, 0);2993 return mem.sliceTo(out_buffer, 0);
2993 },2994 },
2994 .openbsd, .haiku => {2995 .haiku => {
2996 // The only possible issue when looking for the self image path is
2997 // when the buffer is too short.
2998 // TODO replace with proper constants
2999 if (os.find_path(null, 1000, null, out_buffer.ptr, out_buffer.len) != 0)
3000 return error.Overflow;
3001 return mem.sliceTo(out_buffer, 0);
3002 },
3003 .openbsd => {
2995 // OpenBSD doesn't support getting the path of a running process, so try to guess it3004 // OpenBSD doesn't support getting the path of a running process, so try to guess it
2996 if (os.argv.len == 0)3005 if (os.argv.len == 0)
2997 return error.FileNotFound;3006 return error.FileNotFound;