| ... | ... | @@ -543,25 +543,32 @@ pub const ChildProcess = struct { |
| 543 | 543 | |
| 544 | 544 | const PATH = try process.getEnvVarOwned(self.allocator, "PATH"); |
| 545 | 545 | defer self.allocator.free(PATH); |
| 546 | const PATHEXT = try process.getEnvVarOwned(self.allocator, "PATHEXT"); |
| 547 | defer self.allocator.free(PATHEXT); |
| 546 | 548 | |
| 547 | 549 | var it = mem.tokenize(PATH, ";"); |
| 548 | | while (it.next()) |search_path| { |
| 549 | | const joined_path = try fs.path.join(self.allocator, [_][]const u8{ search_path, app_name }); |
| 550 | | defer self.allocator.free(joined_path); |
| 551 | | |
| 552 | | const joined_path_w = try unicode.utf8ToUtf16LeWithNull(self.allocator, joined_path); |
| 553 | | defer self.allocator.free(joined_path_w); |
| 554 | | |
| 555 | | if (windowsCreateProcess(joined_path_w.ptr, cmd_line_w.ptr, envp_ptr, cwd_w_ptr, &siStartInfo, &piProcInfo)) |_| { |
| 556 | | break; |
| 557 | | } else |err| if (err == error.FileNotFound) { |
| 558 | | continue; |
| 559 | | } else { |
| 560 | | return err; |
| 550 | retry: while (it.next()) |search_path| { |
| 551 | var ext_it = mem.tokenize(PATHEXT, ";"); |
| 552 | while (ext_it.next()) |app_ext| { |
| 553 | const app_basename = try mem.concat(self.allocator, u8, [_][]const u8{app_name[0..app_name.len - 1], app_ext}); |
| 554 | defer self.allocator.free(app_basename); |
| 555 | |
| 556 | const joined_path = try fs.path.join(self.allocator, [_][]const u8{ search_path, app_basename }); |
| 557 | defer self.allocator.free(joined_path); |
| 558 | |
| 559 | const joined_path_w = try unicode.utf8ToUtf16LeWithNull(self.allocator, joined_path); |
| 560 | defer self.allocator.free(joined_path_w); |
| 561 | |
| 562 | if (windowsCreateProcess(joined_path_w.ptr, cmd_line_w.ptr, envp_ptr, cwd_w_ptr, &siStartInfo, &piProcInfo)) |_| { |
| 563 | break :retry; |
| 564 | } else |err| switch (err) { |
| 565 | error.FileNotFound => { continue; }, |
| 566 | error.AccessDenied => { continue; }, |
| 567 | else => { return err; }, |
| 568 | } |
| 561 | 569 | } |
| 562 | 570 | } else { |
| 563 | | // Every other error would have been returned earlier. |
| 564 | | return error.FileNotFound; |
| 571 | return no_path_err; // return the original error |
| 565 | 572 | } |
| 566 | 573 | }; |
| 567 | 574 | |