Skip to content

Commit 7439eb5

Browse files
devnexenVexu
authored andcommitted
std.os: selfExePath implementation for haiku
1 parent dc94729 commit 7439eb5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/std/fs.zig

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2913,6 +2913,7 @@ pub const OpenSelfExeError = error{
29132913
/// On Windows, file paths cannot contain these characters:
29142914
/// '/', '*', '?', '"', '<', '>', '|'
29152915
BadPathName,
2916+
Overflow,
29162917
Unexpected,
29172918
} || os.OpenError || SelfExePathError || os.FlockError;
29182919

@@ -2991,7 +2992,15 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
29912992
// TODO could this slice from 0 to out_len instead?
29922993
return mem.sliceTo(out_buffer, 0);
29932994
},
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 => {
29953004
// OpenBSD doesn't support getting the path of a running process, so try to guess it
29963005
if (os.argv.len == 0)
29973006
return error.FileNotFound;

0 commit comments

Comments
 (0)