|
23 | 23 | #include <vector> |
24 | 24 |
|
25 | 25 | #include "absl/strings/match.h" |
| 26 | +#include "absl/strings/str_cat.h" |
26 | 27 | #include "android-base/parseint.h" |
27 | 28 | #include "fmt/format.h" |
28 | 29 | #include "google/protobuf/io/zero_copy_stream_impl.h" |
@@ -240,12 +241,12 @@ Result<void> ParseGuestConfigTxt(const std::string& guest_config_path, |
240 | 241 |
|
241 | 242 | Result<std::vector<GuestConfig>> ReadGuestConfig( |
242 | 243 | const BootImageFlag& boot_image, const KernelPathFlag& kernel_path, |
243 | | - const SystemImageDirFlag& system_image_dir) { |
| 244 | + const SystemImageDirFlag& system_image_dirs) { |
244 | 245 | std::vector<GuestConfig> guest_configs; |
245 | 246 |
|
246 | 247 | const std::string env_path = fmt::format( |
247 | 248 | "PATH={}:{}", StringFromEnv("PATH", ""), DefaultHostArtifactsPath("bin")); |
248 | | - for (int instance_index = 0; instance_index < system_image_dir.Size(); |
| 249 | + for (int instance_index = 0; instance_index < system_image_dirs.Size(); |
249 | 250 | instance_index++) { |
250 | 251 | // extract-ikconfig can be called directly on the boot image since it looks |
251 | 252 | // for the ikconfig header in the image before extracting the config list. |
@@ -306,18 +307,21 @@ Result<std::vector<GuestConfig>> ReadGuestConfig( |
306 | 307 | (guest_config.android_version_number != "13"); |
307 | 308 | } |
308 | 309 |
|
| 310 | + const std::string sys_img_dir = system_image_dirs.ForIndex(instance_index); |
| 311 | + |
309 | 312 | constexpr char kGuestConfigFilename[] = "cuttlefish-guest-config.txtpb"; |
| 313 | + |
310 | 314 | const std::string guest_config_path = |
311 | | - system_image_dir.ForIndex(instance_index) + "/" + kGuestConfigFilename; |
| 315 | + absl::StrCat(sys_img_dir, "/", kGuestConfigFilename); |
312 | 316 | if (FileExists(guest_config_path)) { |
313 | 317 | CF_EXPECT(ParseGuestConfigTextProto(guest_config_path, guest_config)); |
314 | 318 | } else { |
315 | 319 | const std::string android_info_txt_path = |
316 | | - system_image_dir.ForIndex(instance_index) + "/android-info.txt"; |
| 320 | + absl::StrCat(sys_img_dir, "/android-info.txt"); |
317 | 321 | CF_EXPECT(ParseGuestConfigTxt(android_info_txt_path, guest_config)); |
318 | 322 | } |
319 | 323 |
|
320 | | - guest_configs.push_back(guest_config); |
| 324 | + guest_configs.push_back(std::move(guest_config)); |
321 | 325 | } |
322 | 326 | return guest_configs; |
323 | 327 | } |
|
0 commit comments