From 7a05bb5cfbf3560b828c226f4a3bad8c3826b039 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Wed, 23 Mar 2022 18:47:42 +0100 Subject: Apply changes suggested by clang-tidy 11 --- src/buildtool/execution_api/local/local_action.cpp | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/buildtool/execution_api/local/local_action.cpp') diff --git a/src/buildtool/execution_api/local/local_action.cpp b/src/buildtool/execution_api/local/local_action.cpp index 0c71a84b..d8ec8be3 100644 --- a/src/buildtool/execution_api/local/local_action.cpp +++ b/src/buildtool/execution_api/local/local_action.cpp @@ -184,21 +184,24 @@ auto LocalAction::CreateDirectoryStructure( } // create output paths - for (auto const& local_path : output_files_) { - if (not FileSystemManager::CreateDirectory( - (exec_path / local_path).parent_path())) { + auto const create_dir = [this](auto const& dir) { + if (not FileSystemManager::CreateDirectory(dir)) { logger_.Emit(LogLevel::Error, "failed to create output directory"); return false; } - } - for (auto const& local_path : output_dirs_) { - if (not FileSystemManager::CreateDirectory(exec_path / local_path)) { - logger_.Emit(LogLevel::Error, "failed to create output directory"); - return false; - } - } - - return true; + return true; + }; + return std::all_of(output_files_.begin(), + output_files_.end(), + [&exec_path, &create_dir](auto const& local_path) { + auto dir = (exec_path / local_path).parent_path(); + return create_dir(dir); + }) and + std::all_of(output_dirs_.begin(), + output_dirs_.end(), + [&exec_path, &create_dir](auto const& local_path) { + return create_dir(exec_path / local_path); + }); } auto LocalAction::CollectOutputFile(std::filesystem::path const& exec_path, -- cgit v1.2.3