| 687 | } |
| 688 | |
| 689 | ProcessRunner::Results ProcessRunner::run() |
| 690 | { |
| 691 | // check if setHooked() was called after setFromFile(); this needs to |
| 692 | // modify the settings to run the associated executable instead of using |
| 693 | // shell::Open() |
| 694 | |
| 695 | if (shouldRunShell() && m_sp.hooked) { |
| 696 | // this is a non-executable file, but it should be hooked; the associated |
| 697 | // executable needs to be retrieved and run instead |
| 698 | auto assoc = env::getAssociation(m_shellOpen); |
| 699 | if (!assoc.executable.filePath().isEmpty()) { |
| 700 | setBinary(assoc.executable); |
| 701 | setArguments(assoc.formattedCommandLine); |
| 702 | setCurrentDirectory(assoc.executable.absoluteDir()); |
| 703 | m_shellOpen = {}; |
| 704 | } else { |
| 705 | // if it fails, just use the regular shell open |
| 706 | log::error("failed to get the associated executable, running unhooked"); |
| 707 | m_sp.hooked = false; |
| 708 | } |
| 709 | } else if (!shouldRunShell() && !m_sp.hooked) { |
| 710 | // this is an executable that should not be hooked; just run it through |
| 711 | // the shell |
| 712 | m_shellOpen = m_sp.binary; |
| 713 | } |
| 714 | |
| 715 | std::optional<Results> r; |
| 716 | |
| 717 | if (shouldRunShell()) { |
| 718 | r = runShell(); |
| 719 | } else { |
| 720 | r = runBinary(); |
| 721 | } |
| 722 | |
| 723 | if (r) { |
| 724 | // early result: something went wrong and the process cannot be waited for |
| 725 | return *r; |
| 726 | } |
| 727 | |
| 728 | return postRun(); |
| 729 | } |
| 730 | |
| 731 | std::optional<ProcessRunner::Results> ProcessRunner::runShell() |
| 732 | { |
no test coverage detected