diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-06-22 01:23:35 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-06-22 01:23:35 +0000 |
commit | 328a7b9f78ebc97becd8218409dc1552f3cbe8c0 (patch) | |
tree | d2a2390494eac96eb993eef148fa93040b65092a /host | |
parent | 92b50fc42b098d87226badacc94eacd03a7cc582 (diff) | |
parent | a44fee955aeb3dc8f4cf3de078ba02c75386c502 (diff) | |
download | cuttlefish-328a7b9f78ebc97becd8218409dc1552f3cbe8c0.tar.gz |
Merge "Do not return "." and ".." special entries in `DirectoryContents`." into mainemu-35-1-dev
Diffstat (limited to 'host')
-rw-r--r-- | host/commands/assemble_cvd/assemble_cvd.cc | 3 | ||||
-rw-r--r-- | host/commands/host_bugreport/main.cc | 12 | ||||
-rw-r--r-- | host/libs/command_util/snapshot_utils.cc | 4 | ||||
-rw-r--r-- | host/libs/config/custom_actions.cpp | 5 | ||||
-rw-r--r-- | host/libs/config/host_tools_version.cpp | 7 |
5 files changed, 2 insertions, 29 deletions
diff --git a/host/commands/assemble_cvd/assemble_cvd.cc b/host/commands/assemble_cvd/assemble_cvd.cc index c386c3d48..2f0fc18f7 100644 --- a/host/commands/assemble_cvd/assemble_cvd.cc +++ b/host/commands/assemble_cvd/assemble_cvd.cc @@ -319,9 +319,6 @@ Result<const CuttlefishConfig*> InitFilesystemAndCreateConfig( const auto log_files = CF_EXPECT(DirectoryContents(instance.PerInstanceLogPath(""))); for (const auto& filename : log_files) { - if (filename == "." || filename == "..") { - continue; - } const std::string path = instance.PerInstanceLogPath(filename); auto fd = SharedFD::Open(path, O_WRONLY | O_APPEND); CF_EXPECT(fd->IsOpen(), diff --git a/host/commands/host_bugreport/main.cc b/host/commands/host_bugreport/main.cc index fc68c41eb..a414dfc85 100644 --- a/host/commands/host_bugreport/main.cc +++ b/host/commands/host_bugreport/main.cc @@ -62,9 +62,6 @@ Result<void> AddNetsimdLogs(ZipWriter& writer) { auto names = CF_EXPECTF(DirectoryContents(dir), "Cannot read from {} directory.", dir); for (const auto& name : names) { - if (name == "." || name == "..") { - continue; - } SaveFile(writer, "netsimd/" + name, dir + "/" + name); } return {}; @@ -99,9 +96,6 @@ Result<void> CvdHostBugreportMain(int argc, char** argv) { auto logs = CF_EXPECT(DirectoryContents(instance.PerInstancePath("logs")), "Cannot read from logs directory."); for (const auto& log : logs) { - if (log == "." || log == "..") { - continue; - } save("logs/" + log); } } else { @@ -114,18 +108,12 @@ Result<void> CvdHostBugreportMain(int argc, char** argv) { CF_EXPECT(DirectoryContents(instance.PerInstancePath("tombstones")), "Cannot read from tombstones directory."); for (const auto& tombstone : tombstones) { - if (tombstone == "." || tombstone == "..") { - continue; - } save("tombstones/" + tombstone); } auto recordings = CF_EXPECT(DirectoryContents(instance.PerInstancePath("recording")), "Cannot read from recording directory."); for (const auto& recording : recordings) { - if (recording == "." || recording == "..") { - continue; - } save("recording/" + recording); } } diff --git a/host/libs/command_util/snapshot_utils.cc b/host/libs/command_util/snapshot_utils.cc index 4161ee8a4..ccb427a29 100644 --- a/host/libs/command_util/snapshot_utils.cc +++ b/host/libs/command_util/snapshot_utils.cc @@ -70,10 +70,6 @@ Result<void> CopyDirectoryImpl( if (!predicate(src_dir_path + "/" + src_base_path)) { continue; } - if (src_base_path == "." || src_base_path == "..") { - LOG(DEBUG) << "Skipping \"" << src_base_path << "\""; - continue; - } std::string src_path = src_dir_path + "/" + src_base_path; std::string dest_path = dest_dir_path + "/" + src_base_path; diff --git a/host/libs/config/custom_actions.cpp b/host/libs/config/custom_actions.cpp index 9254d57bb..207f5d181 100644 --- a/host/libs/config/custom_actions.cpp +++ b/host/libs/config/custom_actions.cpp @@ -176,11 +176,10 @@ std::string DefaultCustomActionConfig() { CHECK(directory_contents_result.ok()) << directory_contents_result.error().FormatForEnv(); auto custom_action_configs = std::move(*directory_contents_result); - // Two entries are always . and .. - if (custom_action_configs.size() > 3) { + if (custom_action_configs.size() > 1) { LOG(ERROR) << "Expected at most one custom action config in " << custom_action_config_dir << ". Please delete extras."; - } else if (custom_action_configs.size() == 3) { + } else if (custom_action_configs.size() == 1) { for (const auto& config : custom_action_configs) { if (android::base::EndsWithIgnoreCase(config, ".json")) { return custom_action_config_dir + "/" + config; diff --git a/host/libs/config/host_tools_version.cpp b/host/libs/config/host_tools_version.cpp index 9ef895d0b..5c73e5c89 100644 --- a/host/libs/config/host_tools_version.cpp +++ b/host/libs/config/host_tools_version.cpp @@ -48,13 +48,6 @@ static std::map<std::string, uint32_t> DirectoryCrc(const std::string& path) { auto files_result = DirectoryContents(full_path); CHECK(files_result.ok()) << files_result.error().FormatForEnv(); std::vector<std::string> files = std::move(*files_result); - for (auto it = files.begin(); it != files.end();) { - if (*it == "." || *it == "..") { - it = files.erase(it); - } else { - it++; - } - } std::vector<std::future<uint32_t>> calculations; calculations.reserve(files.size()); for (auto& file : files) { |