Fix printing wine version with custom WINELOADER

- Don't call bp::search_path when using WINELOADER. It will return an
  empty string for an absolute path.

- To match the behaviour of the exe wrapper scripts, only print the
  wine version from WINELOADER if the path is executable.
This commit is contained in:
Kira Bruneau
2021-04-26 10:54:03 -04:00
committed by Robbert van der Helm
parent 0c7dbe8a4a
commit 2aadf5256b
+7 -5
View File
@@ -16,6 +16,7 @@
#include "utils.h"
#include <unistd.h>
#include <boost/dll/runtime_symbol_info.hpp>
#include <boost/process/io.hpp>
#include <boost/process/pipe.hpp>
@@ -343,16 +344,17 @@ std::vector<boost::filesystem::path> get_augmented_search_path() {
std::string get_wine_version() {
// The '*.exe' scripts generated by winegcc allow you to override the binary
// used to run Wine, so will will respect this as well
std::string wine_command = "wine";
std::string wine_path;
bp::environment env = boost::this_process::environment();
if (!env["WINELOADER"].empty()) {
wine_command = env["WINELOADER"].to_string();
const std::string wineloader_path = env["WINELOADER"].to_string();
if (access(wineloader_path.c_str(), X_OK) == 0) {
wine_path = wineloader_path;
} else {
wine_path = bp::search_path("wine");
}
bp::ipstream output;
try {
const fs::path wine_path = bp::search_path(wine_command);
bp::system(wine_path, "--version", bp::std_out = output);
} catch (const std::system_error&) {
return "<NOT FOUND>";