aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-08-21 20:52:21 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-08-21 20:52:21 -0400
commit478db39866ff5cc49dca50a8d5a7740d08122d26 (patch)
tree03f7786bbcb72d322d67cb188626065e733ae893 /std
parentea1b21dbdb3d5e680b133be68d174dcc0067fa1e (diff)
downloadzig-478db39866ff5cc49dca50a8d5a7740d08122d26.tar.gz
zig-478db39866ff5cc49dca50a8d5a7740d08122d26.zip
fix selfExePath on macosx
Diffstat (limited to 'std')
-rw-r--r--std/os/index.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/std/os/index.zig b/std/os/index.zig
index e7e187b00f..a0b6e6bf45 100644
--- a/std/os/index.zig
+++ b/std/os/index.zig
@@ -2094,6 +2094,7 @@ test "openSelfExe" {
///
/// On Linux, depends on procfs being mounted. If the currently executing binary has
/// been deleted, the file path looks something like `/a/b/c/exe (deleted)`.
+/// TODO make the return type of this a null terminated pointer
pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) ![]u8 {
switch (builtin.os) {
Os.linux => return readLink(out_buffer, "/proc/self/exe"),
@@ -2117,7 +2118,7 @@ pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) ![]u8 {
var u32_len: u32 = @intCast(u32, out_buffer.len); // TODO shouldn't need this cast
const rc = c._NSGetExecutablePath(out_buffer, &u32_len);
if (rc != 0) return error.NameTooLong;
- return out_buffer[0..u32_len];
+ return mem.toSlice(u8, out_buffer);
},
else => @compileError("Unsupported OS"),
}