Commit 4f998e0c authored by Jaeyong Bae's avatar Jaeyong Bae Committed by Commit Bot

Remove PRIsFP macro in base/file_path.h

This CL means removing duplicate macro in base/file_path.h.
PRIsFP is replaced with PRFilePath.

Bug: 882796
Change-Id: I69f1dc3c13921d0f5d8f1f2de577f27f8db072f4
Reviewed-on: https://chromium-review.googlesource.com/1220406
Commit-Queue: Jaeyong Bae <jdragon.bae@gmail.com>
Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595301}
parent 07fc9d97
...@@ -124,13 +124,20 @@ ...@@ -124,13 +124,20 @@
#define FILE_PATH_USES_WIN_SEPARATORS #define FILE_PATH_USES_WIN_SEPARATORS
#endif // OS_WIN #endif // OS_WIN
// To print path names portably use PRIsFP (based on PRIuS and friends from // To print path names portably use PRFilePath (based on PRIuS and friends from
// C99 and format_macros.h) like this: // C99 and format_macros.h) like this:
// base::StringPrintf("Path is %" PRIsFP ".\n", path.value().c_str()); // base::StringPrintf("Path is %" PRFilePath ".\n", path.value().c_str());
#if defined(OS_WIN) #if defined(OS_WIN)
#define PRIsFP "ls" #define PRFilePath "ls"
#elif defined(OS_POSIX) || defined(OS_FUCHSIA) #elif defined(OS_POSIX) || defined(OS_FUCHSIA)
#define PRIsFP "s" #define PRFilePath "s"
#endif // OS_WIN
// Macros for string literal initialization of FilePath::CharType[].
#if defined(OS_WIN)
#define FILE_PATH_LITERAL(x) L##x
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
#define FILE_PATH_LITERAL(x) x
#endif // OS_WIN #endif // OS_WIN
namespace base { namespace base {
...@@ -455,16 +462,6 @@ BASE_EXPORT std::ostream& operator<<(std::ostream& out, ...@@ -455,16 +462,6 @@ BASE_EXPORT std::ostream& operator<<(std::ostream& out,
} // namespace base } // namespace base
// Macros for string literal initialization of FilePath::CharType[], and for
// using a FilePath::CharType[] in a printf-style format string.
#if defined(OS_WIN)
#define FILE_PATH_LITERAL(x) L ## x
#define PRFilePath "ls"
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
#define FILE_PATH_LITERAL(x) x
#define PRFilePath "s"
#endif // OS_WIN
namespace std { namespace std {
template <> template <>
......
...@@ -152,7 +152,7 @@ void LocalToRemoteSyncer::RunPreflight(std::unique_ptr<SyncTaskToken> token) { ...@@ -152,7 +152,7 @@ void LocalToRemoteSyncer::RunPreflight(std::unique_ptr<SyncTaskToken> token) {
if (!active_ancestor_path.AppendRelativePath(path, &missing_entries)) { if (!active_ancestor_path.AppendRelativePath(path, &missing_entries)) {
NOTREACHED(); NOTREACHED();
token->RecordLog( token->RecordLog(
base::StringPrintf("Detected invalid ancestor: %" PRIsFP, base::StringPrintf("Detected invalid ancestor: %" PRFilePath,
active_ancestor_path.value().c_str())); active_ancestor_path.value().c_str()));
SyncTaskManager::NotifyTaskDone(std::move(token), SYNC_STATUS_FAILED); SyncTaskManager::NotifyTaskDone(std::move(token), SYNC_STATUS_FAILED);
return; return;
......
...@@ -45,13 +45,14 @@ policy::Schema StorageSchemaManifestHandler::GetSchema( ...@@ -45,13 +45,14 @@ policy::Schema StorageSchemaManifestHandler::GetSchema(
} }
file = extension->path().AppendASCII(path); file = extension->path().AppendASCII(path);
if (!base::PathExists(file)) { if (!base::PathExists(file)) {
*error = base::StringPrintf("File does not exist: %" PRIsFP, *error = base::StringPrintf("File does not exist: %" PRFilePath,
file.value().c_str()); file.value().c_str());
return policy::Schema(); return policy::Schema();
} }
std::string content; std::string content;
if (!base::ReadFileToString(file, &content)) { if (!base::ReadFileToString(file, &content)) {
*error = base::StringPrintf("Can't read %" PRIsFP, file.value().c_str()); *error =
base::StringPrintf("Can't read %" PRFilePath, file.value().c_str());
return policy::Schema(); return policy::Schema();
} }
return policy::Schema::Parse(content, error); return policy::Schema::Parse(content, error);
......
...@@ -90,7 +90,7 @@ void SandboxedRarAnalyzer::ReportFileFailure() { ...@@ -90,7 +90,7 @@ void SandboxedRarAnalyzer::ReportFileFailure() {
} }
std::string SandboxedRarAnalyzer::DebugString() const { std::string SandboxedRarAnalyzer::DebugString() const {
return base::StringPrintf("path: %" PRIsFP "; analyzer_ptr_: %p", return base::StringPrintf("path: %" PRFilePath "; analyzer_ptr_: %p",
file_path_.value().c_str(), analyzer_ptr_.get()); file_path_.value().c_str(), analyzer_ptr_.get());
} }
......
...@@ -355,7 +355,7 @@ Status ExecuteSendKeysToElement(Session* session, ...@@ -355,7 +355,7 @@ Status ExecuteSendKeysToElement(Session* session,
if (is_desktop && !base::PathExists(base::FilePath(path_piece))) { if (is_desktop && !base::PathExists(base::FilePath(path_piece))) {
return Status( return Status(
kInvalidArgument, kInvalidArgument,
base::StringPrintf("File not found : %" PRIsFP, base::StringPrintf("File not found : %" PRFilePath,
base::FilePath(path_piece).value().c_str())); base::FilePath(path_piece).value().c_str()));
} }
paths.push_back(base::FilePath(path_piece)); paths.push_back(base::FilePath(path_piece));
......
...@@ -314,7 +314,7 @@ bool ReadFile(const base::FilePath& file_path, ...@@ -314,7 +314,7 @@ bool ReadFile(const base::FilePath& file_path,
return ReadDataInternal( return ReadDataInternal(
mapped_file.data(), mapped_file.length(), root, dict, status, mapped_file.data(), mapped_file.length(), root, dict, status,
base::StringPrintf("file '%" PRIsFP "'", file_path.value().c_str())); base::StringPrintf("file '%" PRFilePath "'", file_path.value().c_str()));
} }
POLICY_EXPORT bool ReadDataInternal(const uint8_t* preg_data, POLICY_EXPORT bool ReadDataInternal(const uint8_t* preg_data,
......
...@@ -18,8 +18,8 @@ TEST(OfflineURLUtilsTest, OfflineRootDirectoryPathTest) { ...@@ -18,8 +18,8 @@ TEST(OfflineURLUtilsTest, OfflineRootDirectoryPathTest) {
base::FilePath offline_directory = base::FilePath offline_directory =
reading_list::OfflineRootDirectoryPath(profile_path); reading_list::OfflineRootDirectoryPath(profile_path);
// Expected value: profile_path/Offline // Expected value: profile_path/Offline
std::string expected = std::string expected = base::StringPrintf(
base::StringPrintf("profile_path%" PRIsFP "Offline", separator.c_str()); "profile_path%" PRFilePath "Offline", separator.c_str());
EXPECT_EQ(expected, offline_directory.AsUTF8Unsafe()); EXPECT_EQ(expected, offline_directory.AsUTF8Unsafe());
} }
...@@ -42,7 +42,7 @@ TEST(OfflineURLUtilsTest, OfflineURLDirectoryAbsolutePathTest) { ...@@ -42,7 +42,7 @@ TEST(OfflineURLUtilsTest, OfflineURLDirectoryAbsolutePathTest) {
reading_list::OfflineURLDirectoryAbsolutePath(profile_path, url); reading_list::OfflineURLDirectoryAbsolutePath(profile_path, url);
// Expected value: profile_path/Offline/0090071ef710946a1263c276284bb3b8 // Expected value: profile_path/Offline/0090071ef710946a1263c276284bb3b8
std::string expected = std::string expected =
base::StringPrintf("profile_path%" PRIsFP "Offline%" PRIsFP base::StringPrintf("profile_path%" PRFilePath "Offline%" PRFilePath
"0090071ef710946a1263c276284bb3b8", "0090071ef710946a1263c276284bb3b8",
separator.c_str(), separator.c_str()); separator.c_str(), separator.c_str());
EXPECT_EQ(expected, offline_directory.AsUTF8Unsafe()); EXPECT_EQ(expected, offline_directory.AsUTF8Unsafe());
...@@ -60,7 +60,8 @@ TEST(OfflineURLUtilsTest, AbsolutePathForRelativePathTest) { ...@@ -60,7 +60,8 @@ TEST(OfflineURLUtilsTest, AbsolutePathForRelativePathTest) {
relative_path); relative_path);
// Expected value: profile_path/Offline/relative/path // Expected value: profile_path/Offline/relative/path
std::string expected = base::StringPrintf( std::string expected = base::StringPrintf(
"profile_path%" PRIsFP "Offline%" PRIsFP "relative%" PRIsFP "path", "profile_path%" PRFilePath "Offline%" PRFilePath "relative%" PRFilePath
"path",
separator.c_str(), separator.c_str(), separator.c_str()); separator.c_str(), separator.c_str(), separator.c_str());
EXPECT_EQ(expected, absolute_path.AsUTF8Unsafe()); EXPECT_EQ(expected, absolute_path.AsUTF8Unsafe());
} }
...@@ -72,14 +73,15 @@ TEST(OfflineURLUtilsTest, OfflinePagePathTest) { ...@@ -72,14 +73,15 @@ TEST(OfflineURLUtilsTest, OfflinePagePathTest) {
base::FilePath offline_page = base::FilePath offline_page =
reading_list::OfflinePagePath(url, reading_list::OFFLINE_TYPE_HTML); reading_list::OfflinePagePath(url, reading_list::OFFLINE_TYPE_HTML);
// Expected value: 0090071ef710946a1263c276284bb3b8/page.html // Expected value: 0090071ef710946a1263c276284bb3b8/page.html
std::string expected_html = std::string expected_html = base::StringPrintf(
base::StringPrintf("0090071ef710946a1263c276284bb3b8%" PRIsFP "page.html", "0090071ef710946a1263c276284bb3b8%" PRFilePath "page.html",
separator.c_str()); separator.c_str());
EXPECT_EQ(expected_html, offline_page.AsUTF8Unsafe()); EXPECT_EQ(expected_html, offline_page.AsUTF8Unsafe());
offline_page = offline_page =
reading_list::OfflinePagePath(url, reading_list::OFFLINE_TYPE_PDF); reading_list::OfflinePagePath(url, reading_list::OFFLINE_TYPE_PDF);
// Expected value: 0090071ef710946a1263c276284bb3b8/file.pdf // Expected value: 0090071ef710946a1263c276284bb3b8/file.pdf
std::string expected_pdf = base::StringPrintf( std::string expected_pdf = base::StringPrintf(
"0090071ef710946a1263c276284bb3b8%" PRIsFP "file.pdf", separator.c_str()); "0090071ef710946a1263c276284bb3b8%" PRFilePath "file.pdf",
separator.c_str());
EXPECT_EQ(expected_pdf, offline_page.AsUTF8Unsafe()); EXPECT_EQ(expected_pdf, offline_page.AsUTF8Unsafe());
} }
...@@ -184,7 +184,7 @@ ListIdentifier GetUrlUwsId() { ...@@ -184,7 +184,7 @@ ListIdentifier GetUrlUwsId() {
std::string GetUmaSuffixForStore(const base::FilePath& file_path) { std::string GetUmaSuffixForStore(const base::FilePath& file_path) {
DCHECK_EQ(kStoreSuffix, file_path.BaseName().Extension()); DCHECK_EQ(kStoreSuffix, file_path.BaseName().Extension());
return base::StringPrintf( return base::StringPrintf(
".%" PRIsFP, file_path.BaseName().RemoveExtension().value().c_str()); ".%" PRFilePath, file_path.BaseName().RemoveExtension().value().c_str());
} }
StoreAndHashPrefix::StoreAndHashPrefix(ListIdentifier list_id, StoreAndHashPrefix::StoreAndHashPrefix(ListIdentifier list_id,
......
...@@ -208,7 +208,7 @@ std::string V4Store::DebugString() const { ...@@ -208,7 +208,7 @@ std::string V4Store::DebugString() const {
std::string state_base64; std::string state_base64;
base::Base64Encode(state_, &state_base64); base::Base64Encode(state_, &state_base64);
return base::StringPrintf("path: %" PRIsFP "; state: %s", return base::StringPrintf("path: %" PRFilePath "; state: %s",
store_path_.value().c_str(), state_base64.c_str()); store_path_.value().c_str(), state_base64.c_str());
} }
......
...@@ -61,7 +61,7 @@ Response MemoryHandler::GetBrowserSamplingProfile( ...@@ -61,7 +61,7 @@ Response MemoryHandler::GetBrowserSamplingProfile(
for (const auto* module : module_cache.GetModules()) { for (const auto* module : module_cache.GetModules()) {
modules->addItem(Memory::Module::Create() modules->addItem(Memory::Module::Create()
.SetName(base::StringPrintf( .SetName(base::StringPrintf(
"%" PRIsFP, module->filename.value().c_str())) "%" PRFilePath, module->filename.value().c_str()))
.SetUuid(module->id) .SetUuid(module->id)
.SetBaseAddress(base::StringPrintf( .SetBaseAddress(base::StringPrintf(
"0x%" PRIxPTR, module->base_address)) "0x%" PRIxPTR, module->base_address))
......
...@@ -103,9 +103,9 @@ static void DumpDirectoryTree(const std::string& origin_name, ...@@ -103,9 +103,9 @@ static void DumpDirectoryTree(const std::string& origin_name,
std::vector<SandboxDirectoryDatabase::FileId> children; std::vector<SandboxDirectoryDatabase::FileId> children;
if (info.is_directory()) { if (info.is_directory()) {
if (!directory_db.ListChildren(id, &children)) { if (!directory_db.ListChildren(id, &children)) {
ShowMessageAndExit(base::StringPrintf("ListChildren failed for %" PRIsFP ShowMessageAndExit(base::StringPrintf(
" (%" PRId64 ")", "ListChildren failed for %" PRFilePath " (%" PRId64 ")",
info.name.c_str(), id)); info.name.c_str(), id));
} }
for (size_t j = children.size(); j; j--) for (size_t j = children.size(); j; j--)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment