Skip to content

Commit

Permalink
fix: 优化exec路径搜索
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Dec 13, 2024
1 parent 286c446 commit 1381eb8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
11 changes: 2 additions & 9 deletions source/MaaAdbControlUnit/Base/ProcessArgvGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,9 @@ std::optional<ProcessArgvGenerator::ProcessArgv> ProcessArgvGenerator::gen(const
string_replace_all_(s, replacement);
}

std::filesystem::path abs_path;
if (auto raw_path = MAA_NS::path(res.front()); raw_path.is_absolute()) {
abs_path = raw_path;
}
else {
abs_path = boost::process::search_path(raw_path);
}

std::filesystem::path abs_path = boost::process::search_path(path(res.front()));
if (!std::filesystem::exists(abs_path)) {
LogError << "exec path not exists" << VAR(abs_path);
LogError << "exec path not exists" << VAR(res.front()) << VAR(abs_path);
return std::nullopt;
}

Expand Down
10 changes: 8 additions & 2 deletions source/MaaFramework/Task/Component/CommandAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

#include "Utils/Codec.h"
#include "Utils/IOStream/BoostIO.hpp"
#include "Utils/ImageIo.h"
#include "Utils/Logger.h"
#include "Utils/Platform.h"
#include "Utils/ImageIo.h"

MAA_TASK_NS_BEGIN

CommandAction::~CommandAction()
{
LogFunc;

for (const auto& p : cached_images_) {
if (!std::filesystem::exists(p)) {
continue;
Expand All @@ -32,7 +34,11 @@ bool CommandAction::run(const MAA_RES_NS::Action::CommandParam& command, const R
{ "{Box}", std::bind(&CommandAction::gen_box, this, std::placeholders::_1) },
};

std::filesystem::path exec = path(command.exec);
std::filesystem::path exec = boost::process::search_path(path(command.exec));
if (!std::filesystem::exists(exec)) {
LogError << "exec not exists" << VAR(command.exec) << VAR(exec);
return false;
}

std::vector<os_string> args;
for (const std::string& arg : command.args) {
Expand Down

0 comments on commit 1381eb8

Please sign in to comment.