diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2019-11-09 01:52:35 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-11-09 01:52:35 +0000 |
commit | 3b821daa1ed816ef36e97ec0d839e01459adc5b4 (patch) | |
tree | d296b496c1f6e061c6e5502ab46b60eac5ac13d8 | |
parent | feed8df3811128e31b126580511482a6e86c4b01 (diff) | |
parent | 9b8a81450e993d4f1baf9bd2fcd3b7a716cf9a70 (diff) | |
download | cuttlefish_common-3b821daa1ed816ef36e97ec0d839e01459adc5b4.tar.gz |
Merge "Only get ".img" files from ANDROID_PRODUCT_OUT"
-rw-r--r-- | host/commands/launch/filesystem_explorer.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/host/commands/launch/filesystem_explorer.cc b/host/commands/launch/filesystem_explorer.cc index 5be4ef05..18ed0d8a 100644 --- a/host/commands/launch/filesystem_explorer.cc +++ b/host/commands/launch/filesystem_explorer.cc @@ -36,7 +36,8 @@ namespace { * This is a shallow exploration that ignores directories, i.e. it only prints * any regular files. */ -std::set<std::string> ReportFiles(const std::string& directory_path) { +std::set<std::string> ReportFiles(const std::string& directory_path, + const std::string& suffix = "") { // TODO(schuffelen): Put this in a common library. DIR* directory = opendir(directory_path.c_str()); if (!directory) { @@ -51,7 +52,12 @@ std::set<std::string> ReportFiles(const std::string& directory_path) { if (entry->d_type == DT_DIR) { continue; } - found_files.insert(directory_path + "/" + std::string(entry->d_name)); + std::string full_path = directory_path + "/" + std::string(entry->d_name); + if (suffix != "" && full_path.compare(full_path.length() - suffix.length(), + suffix.length(), suffix) != 0) { + continue; + } + found_files.insert(full_path); } closedir(directory); return found_files; @@ -94,7 +100,7 @@ cvd::FetcherConfig AvailableFilesReport() { std::string product_out = cvd::StringFromEnv("ANDROID_PRODUCT_OUT", ""); if (product_out != "") { - files.merge(ReportFiles(cvd::AbsolutePath(product_out))); + files.merge(ReportFiles(cvd::AbsolutePath(product_out), ".img")); } files.merge(HeuristicFileReport(current_directory)); |