| ... | ... | @@ -1556,12 +1556,22 @@ pub fn openSelfExe() %io.File { |
| 1556 | 1556 | return io.File.openRead("/proc/self/exe", null); |
| 1557 | 1557 | }, |
| 1558 | 1558 | Os.macosx, Os.ios => { |
| 1559 | | @panic("TODO: openSelfExe on Darwin"); |
| 1559 | var fixed_buffer_mem: [darwin.PATH_MAX]u8 = undefined; |
| 1560 | var fixed_allocator = mem.FixedBufferAllocator.init(fixed_buffer_mem[0..]); |
| 1561 | const self_exe_path = try selfExePath(&fixed_allocator.allocator); |
| 1562 | return io.File.openRead(self_exe_path, null); |
| 1560 | 1563 | }, |
| 1561 | 1564 | else => @compileError("Unsupported OS"), |
| 1562 | 1565 | } |
| 1563 | 1566 | } |
| 1564 | 1567 | |
| 1568 | test "openSelfExe" { |
| 1569 | switch (builtin.os) { |
| 1570 | Os.linux, Os.macosx, Os.ios => (try openSelfExe()).close(), |
| 1571 | else => return, // Unsupported OS. |
| 1572 | } |
| 1573 | } |
| 1574 | |
| 1565 | 1575 | /// Get the path to the current executable. |
| 1566 | 1576 | /// If you only need the directory, use selfExeDirPath. |
| 1567 | 1577 | /// If you only want an open file handle, use openSelfExe. |