| ... | ... | @@ -2177,14 +2177,6 @@ pub fn openSelfExe(flags: File.OpenFlags) OpenSelfExeError!File { |
| 2177 | 2177 | |
| 2178 | 2178 | pub const SelfExePathError = os.ReadLinkError || os.SysCtlError || os.RealPathError; |
| 2179 | 2179 | |
| 2180 | | fn str_containsZ(s: [*:0]const u8, c: u8) bool { |
| 2181 | | var i: usize = 0; |
| 2182 | | while (s[i] != '\x00' and s[i] != c) { |
| 2183 | | i += 1; |
| 2184 | | } |
| 2185 | | return (s[i] == '/'); |
| 2186 | | } |
| 2187 | | |
| 2188 | 2180 | /// `selfExePath` except allocates the result on the heap. |
| 2189 | 2181 | /// Caller owns returned memory. |
| 2190 | 2182 | pub fn selfExePathAlloc(allocator: *Allocator) ![]u8 { |
| ... | ... | @@ -2243,7 +2235,8 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { |
| 2243 | 2235 | .openbsd => { |
| 2244 | 2236 | // OpenBSD doesn't support getting the path of a running process, so try to guess it |
| 2245 | 2237 | if (os.argv.len >= 1) { |
| 2246 | | if (str_containsZ(os.argv[0], '/')) { |
| 2238 | const argv0 = mem.span(os.argv[0]); |
| 2239 | if (mem.indexOf(u8, argv0, "/") != null) { |
| 2247 | 2240 | // argv[0] is a path (relative or absolute): use realpath(3) directly |
| 2248 | 2241 | var real_path_buf: [MAX_PATH_BYTES]u8 = undefined; |
| 2249 | 2242 | const real_path = try os.realpathZ(os.argv[0], &real_path_buf); |