From 173bbef67bd7663c2f7b20b0dc0f847e381373c8 Mon Sep 17 00:00:00 2001 From: Xinhao Yuan Date: Mon, 3 Feb 2025 13:36:46 -0800 Subject: [PATCH] Rename RemotePathRename to RemoteFileRename to support only file renaming. We only need file renaming. PiperOrigin-RevId: 722779470 --- centipede/centipede_interface.cc | 6 +++--- common/BUILD | 7 ++++++- common/remote_file.h | 4 ++-- common/remote_file_oss.cc | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/centipede/centipede_interface.cc b/centipede/centipede_interface.cc index 7c0784de..0e16d1e4 100644 --- a/centipede/centipede_interface.cc +++ b/centipede/centipede_interface.cc @@ -344,7 +344,7 @@ void DeduplicateAndStoreNewCrashes( !crash_metadata.insert(new_crash_metadata).second; if (is_duplicate) continue; CHECK_OK( - RemotePathRename(crashing_input_file, + RemoteFileRename(crashing_input_file, (crashing_dir / crashing_input_file_name).c_str())); } } @@ -642,7 +642,7 @@ int UpdateCorpusDatabaseForFuzzTests( if (!stats_root_path.empty()) { const auto stats_dir = stats_root_path / fuzz_tests_to_run[i]; CHECK_OK(RemoteMkdir(stats_dir.c_str())); - CHECK_OK(RemotePathRename( + CHECK_OK(RemoteFileRename( workdir.FuzzingStatsPath(), (stats_dir / absl::StrCat("fuzzing_stats_", execution_stamp)) .c_str())); @@ -667,7 +667,7 @@ int UpdateCorpusDatabaseForFuzzTests( const std::string file_name = std::filesystem::path(corpus_file).filename(); CHECK_OK( - RemotePathRename(corpus_file, (coverage_dir / file_name).c_str())); + RemoteFileRename(corpus_file, (coverage_dir / file_name).c_str())); } // Deduplicate and update the crashing inputs. diff --git a/common/BUILD b/common/BUILD index 617f5813..e2d55d3f 100644 --- a/common/BUILD +++ b/common/BUILD @@ -246,6 +246,9 @@ cc_library( name = "remote_file_test_lib", testonly = True, srcs = ["remote_file_test.cc"], + defines = select({ + "//conditions:default": [], + }), deps = [ ":logging", ":remote_file", @@ -254,7 +257,9 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/time", "@com_google_googletest//:gtest", - ], + ] + select({ + "//conditions:default": [], + }), alwayslink = True, ) diff --git a/common/remote_file.h b/common/remote_file.h index 08c65d11..f1a6718e 100644 --- a/common/remote_file.h +++ b/common/remote_file.h @@ -136,8 +136,8 @@ absl::Status RemoteGlobMatch(std::string_view glob, absl::StatusOr> RemoteListFiles(std::string_view path, bool recursively); -// Renames `from` to `to`. -absl::Status RemotePathRename(std::string_view from, std::string_view to); +// Renames a file from `from` to `to`. +absl::Status RemoteFileRename(std::string_view from, std::string_view to); // Updates the last-modified time of `path` to the current time. absl::Status RemotePathTouchExistingFile(std::string_view path); diff --git a/common/remote_file_oss.cc b/common/remote_file_oss.cc index 405c195a..a583fe1a 100644 --- a/common/remote_file_oss.cc +++ b/common/remote_file_oss.cc @@ -181,7 +181,7 @@ absl::StatusOr> RemoteListFiles(std::string_view path, LOG(FATAL) << "Filesystem API not supported in iOS/MacOS"; } -absl::Status RemotePathRename(std::string_view from, std::string_view to) { +absl::Status RemoteFileRename(std::string_view from, std::string_view to) { LOG(FATAL) << "Filesystem API not supported in iOS/MacOS"; } @@ -235,7 +235,7 @@ absl::StatusOr> RemoteListFiles(std::string_view path, : list_files(std::filesystem::directory_iterator(path)); } -absl::Status RemotePathRename(std::string_view from, std::string_view to) { +absl::Status RemoteFileRename(std::string_view from, std::string_view to) { std::error_code error; std::filesystem::rename(from, to, error); if (error) {