Skip to content

Commit aee9c00

Browse files
committed
fix: 修复文件夹创建错误
1 parent 19bce7e commit aee9c00

File tree

6 files changed

+11
-19
lines changed

6 files changed

+11
-19
lines changed

source/MaaFramework/Controller/ControllerAgent.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,7 @@ bool ControllerAgent::recording() const
601601
void ControllerAgent::init_recording()
602602
{
603603
auto recording_dir = GlobalOptionMgr::get_instance().log_dir() / "recording";
604-
if (std::error_code ec; !std::filesystem::create_directories(recording_dir, ec)) {
605-
LogError << "failed to create_directories" << VAR(recording_dir) << VAR(ec.message());
606-
return;
607-
}
604+
std::filesystem::create_directories(recording_dir);
608605
recording_path_ = recording_dir / std::format("maa_recording_{}.txt", format_now_for_filename());
609606
}
610607

source/MaaProjectInterface/Impl/Configurator.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ bool Configurator::load(const std::filesystem::path& resource_dir, const std::fi
2424
return false;
2525
}
2626

27-
if (auto cfg_opt = Parser::parse_config(user_dir / kConfigFilename)) {
27+
if (auto cfg_opt = Parser::parse_config(user_dir / kConfigPath)) {
2828
config_ = *std::move(cfg_opt);
2929
first_time_use_ = false;
3030
}
@@ -51,10 +51,9 @@ void Configurator::save(const std::filesystem::path& user_dir)
5151
{
5252
LogInfo << VAR(user_dir);
5353

54-
const auto config_path = user_dir / kConfigFilename;
55-
if (std::error_code ec; config_path.has_parent_path() && !std::filesystem::create_directories(config_path.parent_path(), ec)) {
56-
LogError << "failed to create_directories" << VAR(config_path.parent_path()) << VAR(ec.message());
57-
return;
54+
const auto config_path = user_dir / kConfigPath;
55+
if (config_path.has_parent_path()) {
56+
std::filesystem::create_directories(config_path.parent_path());
5857
}
5958

6059
std::ofstream ofs(config_path);

source/MaaToolkit/Config/GlobalOptionConfig.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ bool GlobalOptionConfig::save() const
8888
{
8989
LogInfo;
9090

91-
if (std::error_code ec; config_path_.has_parent_path() && !std::filesystem::create_directories(config_path_.parent_path(), ec)) {
92-
LogError << "failed to create_directories" << VAR(config_path_.parent_path()) << VAR(ec.message());
93-
return false;
91+
if (config_path_.has_parent_path()) {
92+
std::filesystem::create_directories(config_path_.parent_path());
9493
}
9594

9695
std::ofstream ofs(config_path_, std::ios::out);

source/MaaUtils/Logger/Logger.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@ void Logger::open()
154154
if (log_path_.empty()) {
155155
return;
156156
}
157-
158-
if (std::error_code ec; !std::filesystem::create_directories(log_dir_, ec)) {
159-
return;
160-
}
157+
std::filesystem::create_directories(log_dir_);
161158

162159
std::unique_lock trace_lock(trace_mutex_);
163160
if (ofs_.is_open()) {

source/include/ProjectInterface/Configurator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ MAA_PROJECT_INTERFACE_NS_BEGIN
1010
class Configurator
1111
{
1212
static constexpr std::string_view kInterfaceFilename = "interface.json";
13-
static constexpr std::string_view kConfigFilename = "config/maa_pi_config.json";
13+
static constexpr std::string_view kConfigPath = "config/maa_pi_config.json";
1414

1515
public:
1616
bool load(const std::filesystem::path& project_dir, const std::filesystem::path& user_dir);

source/include/Utils/ImageIo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ inline cv::Mat imread(const std::string& utf8_path, int flags = cv::IMREAD_COLOR
2828

2929
inline bool imwrite(const std::filesystem::path& path, cv::InputArray img)
3030
{
31-
if (std::error_code ec; path.has_parent_path() && !std::filesystem::create_directories(path.parent_path(), ec)) {
32-
return false;
31+
if (path.has_parent_path()) {
32+
std::filesystem::create_directories(path.parent_path());
3333
}
3434

3535
auto ext = path_to_utf8_string(path.extension());

0 commit comments

Comments
 (0)