diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-01 19:41:02 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-01 19:41:02 +0000 |
commit | 918efbf64de58c82ffa3cd8799d9ad822811a37a (patch) | |
tree | 5ceffb5e1576177d75f1aa8546bcae074df63c1e /base | |
parent | e07f44f6b208541c9602bb9cc5f311612aaab64a (diff) | |
download | chromium_src-918efbf64de58c82ffa3cd8799d9ad822811a37a.zip chromium_src-918efbf64de58c82ffa3cd8799d9ad822811a37a.tar.gz chromium_src-918efbf64de58c82ffa3cd8799d9ad822811a37a.tar.bz2 |
Move file_util::Delete to the base namespace
BUG=
Review URL: https://codereview.chromium.org/16950028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209475 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/debug/trace_event_win_unittest.cc | 2 | ||||
-rw-r--r-- | base/file_util.h | 12 | ||||
-rw-r--r-- | base/file_util_posix.cc | 61 | ||||
-rw-r--r-- | base/file_util_unittest.cc | 54 | ||||
-rw-r--r-- | base/file_util_win.cc | 36 | ||||
-rw-r--r-- | base/files/file_path_watcher_browsertest.cc | 24 | ||||
-rw-r--r-- | base/files/file_util_proxy.cc | 2 | ||||
-rw-r--r-- | base/files/file_util_proxy_unittest.cc | 2 | ||||
-rw-r--r-- | base/files/important_file_writer.cc | 6 | ||||
-rw-r--r-- | base/files/scoped_temp_dir.cc | 2 | ||||
-rw-r--r-- | base/files/scoped_temp_dir_unittest.cc | 2 | ||||
-rw-r--r-- | base/json/json_value_serializer_unittest.cc | 4 | ||||
-rw-r--r-- | base/memory/shared_memory_posix.cc | 2 | ||||
-rw-r--r-- | base/prefs/json_pref_store_unittest.cc | 2 | ||||
-rw-r--r-- | base/test/test_file_util.h | 2 | ||||
-rw-r--r-- | base/test/test_file_util_posix.cc | 2 | ||||
-rw-r--r-- | base/test/test_file_util_win.cc | 2 | ||||
-rw-r--r-- | base/win/event_trace_consumer_unittest.cc | 4 | ||||
-rw-r--r-- | base/win/event_trace_controller_unittest.cc | 4 |
19 files changed, 117 insertions, 108 deletions
diff --git a/base/debug/trace_event_win_unittest.cc b/base/debug/trace_event_win_unittest.cc index 786b9d5..7d2a212 100644 --- a/base/debug/trace_event_win_unittest.cc +++ b/base/debug/trace_event_win_unittest.cc @@ -157,7 +157,7 @@ class TraceEventWinTest: public testing::Test { EXPECT_HRESULT_SUCCEEDED(controller_.Stop(&prop)); if (!log_file_.value().empty()) - file_util::Delete(log_file_, false); + base::Delete(log_file_, false); } void ExpectEvent(REFGUID guid, diff --git a/base/file_util.h b/base/file_util.h index 2bf46a9..0fa7017 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -57,10 +57,6 @@ BASE_EXPORT FilePath MakeAbsoluteFilePath(const FilePath& input); // particularly speedy in any platform. BASE_EXPORT int64 ComputeDirectorySize(const FilePath& root_path); -} // namespace base - -namespace file_util { - // Deletes the given path, whether it's a file or a directory. // If it's a directory, it's perfectly happy to delete all of the // directory's contents. Passing true to recursive deletes @@ -73,7 +69,13 @@ namespace file_util { // // WARNING: USING THIS WITH recursive==true IS EQUIVALENT // TO "rm -rf", SO USE WITH CAUTION. -BASE_EXPORT bool Delete(const base::FilePath& path, bool recursive); +BASE_EXPORT bool Delete(const FilePath& path, bool recursive); + +} // namespace base + +// ----------------------------------------------------------------------------- + +namespace file_util { #if defined(OS_WIN) // Schedules to delete the given path, whether it's a file or a directory, until diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index 77e080a..afb34b4 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -58,24 +58,8 @@ #include "base/chromeos/chromeos_version.h" #endif -using base::FileEnumerator; -using base::FilePath; -using base::MakeAbsoluteFilePath; - namespace base { -FilePath MakeAbsoluteFilePath(const FilePath& input) { - base::ThreadRestrictions::AssertIOAllowed(); - char full_path[PATH_MAX]; - if (realpath(input.value().c_str(), full_path) == NULL) - return FilePath(); - return FilePath(full_path); -} - -} // namespace base - -namespace file_util { - namespace { #if defined(OS_BSD) || defined(OS_MACOSX) @@ -152,16 +136,12 @@ bool VerifySpecificPathControlledByUser(const FilePath& path, } // namespace -static std::string TempFileName() { -#if defined(OS_MACOSX) - return base::StringPrintf(".%s.XXXXXX", base::mac::BaseBundleID()); -#endif - -#if defined(GOOGLE_CHROME_BUILD) - return std::string(".com.google.Chrome.XXXXXX"); -#else - return std::string(".org.chromium.Chromium.XXXXXX"); -#endif +FilePath MakeAbsoluteFilePath(const FilePath& input) { + ThreadRestrictions::AssertIOAllowed(); + char full_path[PATH_MAX]; + if (realpath(input.value().c_str(), full_path) == NULL) + return FilePath(); + return FilePath(full_path); } // TODO(erikkay): The Windows version of this accepts paths like "foo/bar/*" @@ -169,7 +149,7 @@ static std::string TempFileName() { // that functionality. If not, remove from file_util_win.cc, otherwise add it // here. bool Delete(const FilePath& path, bool recursive) { - base::ThreadRestrictions::AssertIOAllowed(); + ThreadRestrictions::AssertIOAllowed(); const char* path_str = path.value().c_str(); stat_wrapper_t file_info; int test = CallLstat(path_str, &file_info); @@ -205,6 +185,33 @@ bool Delete(const FilePath& path, bool recursive) { return success; } +} // namespace base + +// ----------------------------------------------------------------------------- + +namespace file_util { + +using base::stat_wrapper_t; +using base::CallStat; +using base::CallLstat; +using base::FileEnumerator; +using base::FilePath; +using base::MakeAbsoluteFilePath; +using base::RealPath; +using base::VerifySpecificPathControlledByUser; + +static std::string TempFileName() { +#if defined(OS_MACOSX) + return base::StringPrintf(".%s.XXXXXX", base::mac::BaseBundleID()); +#endif + +#if defined(GOOGLE_CHROME_BUILD) + return std::string(".com.google.Chrome.XXXXXX"); +#else + return std::string(".org.chromium.Chromium.XXXXXX"); +#endif +} + bool MoveUnsafe(const FilePath& from_path, const FilePath& to_path) { base::ThreadRestrictions::AssertIOAllowed(); // Windows compatibility: if to_path exists, from_path and to_path diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc index cbe8f26..7626957 100644 --- a/base/file_util_unittest.cc +++ b/base/file_util_unittest.cc @@ -738,9 +738,9 @@ TEST_F(FileUtilTest, DeleteNonExistent) { FilePath non_existent = temp_dir_.path().AppendASCII("bogus_file_dne.foobar"); ASSERT_FALSE(file_util::PathExists(non_existent)); - EXPECT_TRUE(file_util::Delete(non_existent, false)); + EXPECT_TRUE(base::Delete(non_existent, false)); ASSERT_FALSE(file_util::PathExists(non_existent)); - EXPECT_TRUE(file_util::Delete(non_existent, true)); + EXPECT_TRUE(base::Delete(non_existent, true)); ASSERT_FALSE(file_util::PathExists(non_existent)); } @@ -751,7 +751,7 @@ TEST_F(FileUtilTest, DeleteFile) { ASSERT_TRUE(file_util::PathExists(file_name)); // Make sure it's deleted - EXPECT_TRUE(file_util::Delete(file_name, false)); + EXPECT_TRUE(base::Delete(file_name, false)); EXPECT_FALSE(file_util::PathExists(file_name)); // Test recursive case, create a new file @@ -760,7 +760,7 @@ TEST_F(FileUtilTest, DeleteFile) { ASSERT_TRUE(file_util::PathExists(file_name)); // Make sure it's deleted - EXPECT_TRUE(file_util::Delete(file_name, true)); + EXPECT_TRUE(base::Delete(file_name, true)); EXPECT_FALSE(file_util::PathExists(file_name)); } @@ -777,7 +777,7 @@ TEST_F(FileUtilTest, DeleteSymlinkToExistentFile) { << "Failed to create symlink."; // Delete the symbolic link. - EXPECT_TRUE(file_util::Delete(file_link, false)); + EXPECT_TRUE(base::Delete(file_link, false)); // Make sure original file is not deleted. EXPECT_FALSE(file_util::PathExists(file_link)); @@ -799,7 +799,7 @@ TEST_F(FileUtilTest, DeleteSymlinkToNonExistentFile) { EXPECT_FALSE(file_util::PathExists(file_link)); // Delete the symbolic link. - EXPECT_TRUE(file_util::Delete(file_link, false)); + EXPECT_TRUE(base::Delete(file_link, false)); // Make sure the symbolic link is deleted. EXPECT_FALSE(file_util::IsLink(file_link)); @@ -843,7 +843,7 @@ TEST_F(FileUtilTest, ChangeFilePermissionsAndRead) { file_util::ReadFile(file_name, buffer, buffer_size)); // Delete the file. - EXPECT_TRUE(file_util::Delete(file_name, false)); + EXPECT_TRUE(base::Delete(file_name, false)); EXPECT_FALSE(file_util::PathExists(file_name)); delete[] buffer; @@ -888,7 +888,7 @@ TEST_F(FileUtilTest, ChangeFilePermissionsAndWrite) { EXPECT_TRUE(file_util::PathIsWritable(file_name)); // Delete the file. - EXPECT_TRUE(file_util::Delete(file_name, false)); + EXPECT_TRUE(base::Delete(file_name, false)); EXPECT_FALSE(file_util::PathExists(file_name)); } @@ -940,7 +940,7 @@ TEST_F(FileUtilTest, ChangeDirectoryPermissionsAndEnumerate) { EXPECT_EQ(c2.size(), 1); // Delete the file. - EXPECT_TRUE(file_util::Delete(subdir_path, true)); + EXPECT_TRUE(base::Delete(subdir_path, true)); EXPECT_FALSE(file_util::PathExists(subdir_path)); } @@ -965,12 +965,12 @@ TEST_F(FileUtilTest, DeleteWildCard) { directory_contents = directory_contents.Append(FPL("*")); // Delete non-recursively and check that only the file is deleted - EXPECT_TRUE(file_util::Delete(directory_contents, false)); + EXPECT_TRUE(base::Delete(directory_contents, false)); EXPECT_FALSE(file_util::PathExists(file_name)); EXPECT_TRUE(file_util::PathExists(subdir_path)); // Delete recursively and make sure all contents are deleted - EXPECT_TRUE(file_util::Delete(directory_contents, true)); + EXPECT_TRUE(base::Delete(directory_contents, true)); EXPECT_FALSE(file_util::PathExists(file_name)); EXPECT_FALSE(file_util::PathExists(subdir_path)); } @@ -988,11 +988,11 @@ TEST_F(FileUtilTest, DeleteNonExistantWildCard) { directory_contents = directory_contents.Append(FPL("*")); // Delete non-recursively and check nothing got deleted - EXPECT_TRUE(file_util::Delete(directory_contents, false)); + EXPECT_TRUE(base::Delete(directory_contents, false)); EXPECT_TRUE(file_util::PathExists(subdir_path)); // Delete recursively and check nothing got deleted - EXPECT_TRUE(file_util::Delete(directory_contents, true)); + EXPECT_TRUE(base::Delete(directory_contents, true)); EXPECT_TRUE(file_util::PathExists(subdir_path)); } #endif @@ -1017,11 +1017,11 @@ TEST_F(FileUtilTest, DeleteDirNonRecursive) { ASSERT_TRUE(file_util::PathExists(subdir_path2)); // Delete non-recursively and check that the empty dir got deleted - EXPECT_TRUE(file_util::Delete(subdir_path2, false)); + EXPECT_TRUE(base::Delete(subdir_path2, false)); EXPECT_FALSE(file_util::PathExists(subdir_path2)); // Delete non-recursively and check that nothing got deleted - EXPECT_FALSE(file_util::Delete(test_subdir, false)); + EXPECT_FALSE(base::Delete(test_subdir, false)); EXPECT_TRUE(file_util::PathExists(test_subdir)); EXPECT_TRUE(file_util::PathExists(file_name)); EXPECT_TRUE(file_util::PathExists(subdir_path1)); @@ -1047,11 +1047,11 @@ TEST_F(FileUtilTest, DeleteDirRecursive) { ASSERT_TRUE(file_util::PathExists(subdir_path2)); // Delete recursively and check that the empty dir got deleted - EXPECT_TRUE(file_util::Delete(subdir_path2, true)); + EXPECT_TRUE(base::Delete(subdir_path2, true)); EXPECT_FALSE(file_util::PathExists(subdir_path2)); // Delete recursively and check that everything got deleted - EXPECT_TRUE(file_util::Delete(test_subdir, true)); + EXPECT_TRUE(base::Delete(test_subdir, true)); EXPECT_FALSE(file_util::PathExists(file_name)); EXPECT_FALSE(file_util::PathExists(subdir_path1)); EXPECT_FALSE(file_util::PathExists(test_subdir)); @@ -1695,7 +1695,7 @@ TEST_F(FileUtilTest, CreateTemporaryFileTest) { for (int i = 0; i < 3; i++) EXPECT_FALSE(temp_files[i] == temp_files[(i+1)%3]); for (int i = 0; i < 3; i++) - EXPECT_TRUE(file_util::Delete(temp_files[i], false)); + EXPECT_TRUE(base::Delete(temp_files[i], false)); } TEST_F(FileUtilTest, CreateAndOpenTemporaryFileTest) { @@ -1718,7 +1718,7 @@ TEST_F(FileUtilTest, CreateAndOpenTemporaryFileTest) { // Close and delete. for (i = 0; i < 3; ++i) { EXPECT_TRUE(file_util::CloseFile(fps[i])); - EXPECT_TRUE(file_util::Delete(names[i], false)); + EXPECT_TRUE(base::Delete(names[i], false)); } } @@ -1727,7 +1727,7 @@ TEST_F(FileUtilTest, CreateNewTempDirectoryTest) { ASSERT_TRUE(file_util::CreateNewTempDirectory(FilePath::StringType(), &temp_dir)); EXPECT_TRUE(file_util::PathExists(temp_dir)); - EXPECT_TRUE(file_util::Delete(temp_dir, false)); + EXPECT_TRUE(base::Delete(temp_dir, false)); } TEST_F(FileUtilTest, CreateNewTemporaryDirInDirTest) { @@ -1738,7 +1738,7 @@ TEST_F(FileUtilTest, CreateNewTemporaryDirInDirTest) { &new_dir)); EXPECT_TRUE(file_util::PathExists(new_dir)); EXPECT_TRUE(temp_dir_.path().IsParent(new_dir)); - EXPECT_TRUE(file_util::Delete(new_dir, false)); + EXPECT_TRUE(base::Delete(new_dir, false)); } TEST_F(FileUtilTest, GetShmemTempDirTest) { @@ -1771,7 +1771,7 @@ TEST_F(FileUtilTest, CreateDirectoryTest) { EXPECT_TRUE(file_util::PathExists(test_path)); EXPECT_FALSE(file_util::CreateDirectory(test_path)); - EXPECT_TRUE(file_util::Delete(test_root, true)); + EXPECT_TRUE(base::Delete(test_root, true)); EXPECT_FALSE(file_util::PathExists(test_root)); EXPECT_FALSE(file_util::PathExists(test_path)); @@ -1817,9 +1817,9 @@ TEST_F(FileUtilTest, DetectDirectoryTest) { CreateTextFile(test_path, L"test file"); EXPECT_TRUE(file_util::PathExists(test_path)); EXPECT_FALSE(file_util::DirectoryExists(test_path)); - EXPECT_TRUE(file_util::Delete(test_path, false)); + EXPECT_TRUE(base::Delete(test_path, false)); - EXPECT_TRUE(file_util::Delete(test_root, true)); + EXPECT_TRUE(base::Delete(test_root, true)); } TEST_F(FileUtilTest, FileEnumeratorTest) { @@ -1937,13 +1937,13 @@ TEST_F(FileUtilTest, AppendToFile) { // Create a fresh, empty copy of this directory. if (file_util::PathExists(data_dir)) { - ASSERT_TRUE(file_util::Delete(data_dir, true)); + ASSERT_TRUE(base::Delete(data_dir, true)); } ASSERT_TRUE(file_util::CreateDirectory(data_dir)); // Create a fresh, empty copy of this directory. if (file_util::PathExists(data_dir)) { - ASSERT_TRUE(file_util::Delete(data_dir, true)); + ASSERT_TRUE(base::Delete(data_dir, true)); } ASSERT_TRUE(file_util::CreateDirectory(data_dir)); FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt"))); @@ -1965,7 +1965,7 @@ TEST_F(FileUtilTest, TouchFile) { // Create a fresh, empty copy of this directory. if (file_util::PathExists(data_dir)) { - ASSERT_TRUE(file_util::Delete(data_dir, true)); + ASSERT_TRUE(base::Delete(data_dir, true)); } ASSERT_TRUE(file_util::CreateDirectory(data_dir)); diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 39da988..44367a0 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -27,23 +27,8 @@ #include "base/win/scoped_handle.h" #include "base/win/windows_version.h" -using base::FilePath; -using base::g_bug108724_debug; - namespace base { -FilePath MakeAbsoluteFilePath(const FilePath& input) { - base::ThreadRestrictions::AssertIOAllowed(); - wchar_t file_path[MAX_PATH]; - if (!_wfullpath(file_path, input.value().c_str(), MAX_PATH)) - return FilePath(); - return FilePath(file_path); -} - -} // namespace base - -namespace file_util { - namespace { const DWORD kFileShareAll = @@ -51,8 +36,16 @@ const DWORD kFileShareAll = } // namespace +FilePath MakeAbsoluteFilePath(const FilePath& input) { + ThreadRestrictions::AssertIOAllowed(); + wchar_t file_path[MAX_PATH]; + if (!_wfullpath(file_path, input.value().c_str(), MAX_PATH)) + return FilePath(); + return FilePath(file_path); +} + bool Delete(const FilePath& path, bool recursive) { - base::ThreadRestrictions::AssertIOAllowed(); + ThreadRestrictions::AssertIOAllowed(); if (path.value().length() >= MAX_PATH) return false; @@ -60,8 +53,8 @@ bool Delete(const FilePath& path, bool recursive) { if (!recursive) { // If not recursing, then first check to see if |path| is a directory. // If it is, then remove it with RemoveDirectory. - base::PlatformFileInfo file_info; - if (GetFileInfo(path, &file_info) && file_info.is_directory) + PlatformFileInfo file_info; + if (file_util::GetFileInfo(path, &file_info) && file_info.is_directory) return RemoveDirectory(path.value().c_str()) != 0; // Otherwise, it's a file, wildcard or non-existant. Try DeleteFile first @@ -105,6 +98,13 @@ bool Delete(const FilePath& path, bool recursive) { return (err == 0 || err == ERROR_FILE_NOT_FOUND || err == 0x402); } +} // namespace base + +namespace file_util { + +using base::FilePath; +using base::kFileShareAll; + bool DeleteAfterReboot(const FilePath& path) { base::ThreadRestrictions::AssertIOAllowed(); diff --git a/base/files/file_path_watcher_browsertest.cc b/base/files/file_path_watcher_browsertest.cc index 7c37432..2a8b0cf 100644 --- a/base/files/file_path_watcher_browsertest.cc +++ b/base/files/file_path_watcher_browsertest.cc @@ -274,7 +274,7 @@ TEST_F(FilePathWatcherTest, DeletedFile) { ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false)); // Now make sure we get notified if the file is deleted. - file_util::Delete(test_file(), false); + base::Delete(test_file(), false); ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); } @@ -369,7 +369,7 @@ TEST_F(FilePathWatcherTest, NonExistentDirectory) { VLOG(1) << "Waiting for file change"; ASSERT_TRUE(WaitForEvents()); - ASSERT_TRUE(file_util::Delete(file, false)); + ASSERT_TRUE(base::Delete(file, false)); VLOG(1) << "Waiting for file deletion"; ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); @@ -421,7 +421,7 @@ TEST_F(FilePathWatcherTest, DisappearingDirectory) { scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); ASSERT_TRUE(SetupWatch(file, &watcher, delegate.get(), false)); - ASSERT_TRUE(file_util::Delete(dir, true)); + ASSERT_TRUE(base::Delete(dir, true)); ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); } @@ -433,7 +433,7 @@ TEST_F(FilePathWatcherTest, DeleteAndRecreate) { scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false)); - ASSERT_TRUE(file_util::Delete(test_file(), false)); + ASSERT_TRUE(base::Delete(test_file(), false)); VLOG(1) << "Waiting for file deletion"; ASSERT_TRUE(WaitForEvents()); @@ -466,7 +466,7 @@ TEST_F(FilePathWatcherTest, WatchDirectory) { ASSERT_TRUE(WaitForEvents()); #endif // !OS_MACOSX - ASSERT_TRUE(file_util::Delete(file1, false)); + ASSERT_TRUE(base::Delete(file1, false)); VLOG(1) << "Waiting for file1 deletion"; ASSERT_TRUE(WaitForEvents()); @@ -548,11 +548,11 @@ TEST_F(FilePathWatcherTest, RecursiveWatch) { ASSERT_TRUE(WaitForEvents()); // Delete "$dir/subdir/subdir_file1". - ASSERT_TRUE(file_util::Delete(subdir_file1, false)); + ASSERT_TRUE(base::Delete(subdir_file1, false)); ASSERT_TRUE(WaitForEvents()); // Delete "$dir/subdir/subdir_child_dir/child_dir_file1". - ASSERT_TRUE(file_util::Delete(child_dir_file1, false)); + ASSERT_TRUE(base::Delete(child_dir_file1, false)); ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); } @@ -640,7 +640,7 @@ TEST_F(FilePathWatcherTest, DeleteLink) { ASSERT_TRUE(SetupWatch(test_link(), &watcher, delegate.get(), false)); // Now make sure we get notified if the link is deleted. - ASSERT_TRUE(file_util::Delete(test_link(), false)); + ASSERT_TRUE(base::Delete(test_link(), false)); ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); } @@ -687,7 +687,7 @@ TEST_F(FilePathWatcherTest, DeleteTargetLinkedFile) { ASSERT_TRUE(SetupWatch(test_link(), &watcher, delegate.get(), false)); // Now make sure we get notified if the target file is deleted. - ASSERT_TRUE(file_util::Delete(test_file(), false)); + ASSERT_TRUE(base::Delete(test_file(), false)); ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); } @@ -715,7 +715,7 @@ TEST_F(FilePathWatcherTest, LinkedDirectoryPart1) { VLOG(1) << "Waiting for file change"; ASSERT_TRUE(WaitForEvents()); - ASSERT_TRUE(file_util::Delete(file, false)); + ASSERT_TRUE(base::Delete(file, false)); VLOG(1) << "Waiting for file deletion"; ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); @@ -745,7 +745,7 @@ TEST_F(FilePathWatcherTest, LinkedDirectoryPart2) { VLOG(1) << "Waiting for file change"; ASSERT_TRUE(WaitForEvents()); - ASSERT_TRUE(file_util::Delete(file, false)); + ASSERT_TRUE(base::Delete(file, false)); VLOG(1) << "Waiting for file deletion"; ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); @@ -773,7 +773,7 @@ TEST_F(FilePathWatcherTest, LinkedDirectoryPart3) { VLOG(1) << "Waiting for file change"; ASSERT_TRUE(WaitForEvents()); - ASSERT_TRUE(file_util::Delete(file, false)); + ASSERT_TRUE(base::Delete(file, false)); VLOG(1) << "Waiting for file deletion"; ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); diff --git a/base/files/file_util_proxy.cc b/base/files/file_util_proxy.cc index a1c568a..9f65da8e 100644 --- a/base/files/file_util_proxy.cc +++ b/base/files/file_util_proxy.cc @@ -213,7 +213,7 @@ PlatformFileError DeleteAdapter(const FilePath& file_path, bool recursive) { if (!file_util::PathExists(file_path)) { return PLATFORM_FILE_ERROR_NOT_FOUND; } - if (!file_util::Delete(file_path, recursive)) { + if (!base::Delete(file_path, recursive)) { if (!recursive && !file_util::IsDirectoryEmpty(file_path)) { return PLATFORM_FILE_ERROR_NOT_EMPTY; } diff --git a/base/files/file_util_proxy_unittest.cc b/base/files/file_util_proxy_unittest.cc index ef23fd8..a4ba571 100644 --- a/base/files/file_util_proxy_unittest.cc +++ b/base/files/file_util_proxy_unittest.cc @@ -219,7 +219,7 @@ TEST_F(FileUtilProxyTest, CreateTemporary) { EXPECT_EQ("test", data); // Make sure we can & do delete the created file to prevent leaks on the bots. - EXPECT_TRUE(file_util::Delete(path_, false)); + EXPECT_TRUE(base::Delete(path_, false)); } TEST_F(FileUtilProxyTest, GetFileInfo_File) { diff --git a/base/files/important_file_writer.cc b/base/files/important_file_writer.cc index ab62cc3..f10e7e6 100644 --- a/base/files/important_file_writer.cc +++ b/base/files/important_file_writer.cc @@ -73,20 +73,20 @@ bool ImportantFileWriter::WriteFileAtomically(const FilePath& path, if (!ClosePlatformFile(tmp_file)) { LogFailure(path, FAILED_CLOSING, "failed to close temporary file"); - file_util::Delete(tmp_file_path, false); + base::Delete(tmp_file_path, false); return false; } if (bytes_written < static_cast<int>(data.length())) { LogFailure(path, FAILED_WRITING, "error writing, bytes_written=" + IntToString(bytes_written)); - file_util::Delete(tmp_file_path, false); + base::Delete(tmp_file_path, false); return false; } if (!file_util::ReplaceFile(tmp_file_path, path)) { LogFailure(path, FAILED_RENAMING, "could not rename temporary file"); - file_util::Delete(tmp_file_path, false); + base::Delete(tmp_file_path, false); return false; } diff --git a/base/files/scoped_temp_dir.cc b/base/files/scoped_temp_dir.cc index 509f808..5666ce1 100644 --- a/base/files/scoped_temp_dir.cc +++ b/base/files/scoped_temp_dir.cc @@ -64,7 +64,7 @@ bool ScopedTempDir::Delete() { if (path_.empty()) return false; - bool ret = file_util::Delete(path_, true); + bool ret = base::Delete(path_, true); if (ret) { // We only clear the path if deleted the directory. path_.clear(); diff --git a/base/files/scoped_temp_dir_unittest.cc b/base/files/scoped_temp_dir_unittest.cc index 8497ac6..7acec84 100644 --- a/base/files/scoped_temp_dir_unittest.cc +++ b/base/files/scoped_temp_dir_unittest.cc @@ -77,7 +77,7 @@ TEST(ScopedTempDir, UniqueTempDirUnderPath) { EXPECT_TRUE(test_path.value().find(base_path.value()) != std::string::npos); } EXPECT_FALSE(file_util::DirectoryExists(test_path)); - file_util::Delete(base_path, true); + base::Delete(base_path, true); } TEST(ScopedTempDir, MultipleInvocations) { diff --git a/base/json/json_value_serializer_unittest.cc b/base/json/json_value_serializer_unittest.cc index b428e2a..78be11e 100644 --- a/base/json/json_value_serializer_unittest.cc +++ b/base/json/json_value_serializer_unittest.cc @@ -425,7 +425,7 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) { // Now compare file contents. EXPECT_TRUE(file_util::TextContentsEqual(original_file_path, written_file_path)); - EXPECT_TRUE(file_util::Delete(written_file_path, false)); + EXPECT_TRUE(base::Delete(written_file_path, false)); } TEST_F(JSONFileValueSerializerTest, RoundtripNested) { @@ -453,7 +453,7 @@ TEST_F(JSONFileValueSerializerTest, RoundtripNested) { // Now compare file contents. EXPECT_TRUE(file_util::TextContentsEqual(original_file_path, written_file_path)); - EXPECT_TRUE(file_util::Delete(written_file_path, false)); + EXPECT_TRUE(base::Delete(written_file_path, false)); } TEST_F(JSONFileValueSerializerTest, NoWhitespace) { diff --git a/base/memory/shared_memory_posix.cc b/base/memory/shared_memory_posix.cc index 66f5848..5d580d0 100644 --- a/base/memory/shared_memory_posix.cc +++ b/base/memory/shared_memory_posix.cc @@ -201,7 +201,7 @@ bool SharedMemory::Delete(const std::string& name) { return false; if (file_util::PathExists(path)) { - return file_util::Delete(path, false); + return base::Delete(path, false); } // Doesn't exist, so success. diff --git a/base/prefs/json_pref_store_unittest.cc b/base/prefs/json_pref_store_unittest.cc index 63b9e02..77f0c0d 100644 --- a/base/prefs/json_pref_store_unittest.cc +++ b/base/prefs/json_pref_store_unittest.cc @@ -148,7 +148,7 @@ void RunBasicJsonPrefStoreTest(JsonPrefStore* pref_store, pref_store->CommitPendingWrite(); RunLoop().RunUntilIdle(); EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, output_file)); - ASSERT_TRUE(file_util::Delete(output_file, false)); + ASSERT_TRUE(base::Delete(output_file, false)); } TEST_F(JsonPrefStoreTest, Basic) { diff --git a/base/test/test_file_util.h b/base/test/test_file_util.h index 418c480..cf20221 100644 --- a/base/test/test_file_util.h +++ b/base/test/test_file_util.h @@ -27,7 +27,7 @@ bool EvictFileFromSystemCacheWithRetry(const FilePath& file); // TODO(brettw) move all of this to the base namespace. namespace file_util { -// Wrapper over file_util::Delete. On Windows repeatedly invokes Delete in case +// Wrapper over base::Delete. On Windows repeatedly invokes Delete in case // of failure to workaround Windows file locking semantics. Returns true on // success. bool DieFileDie(const base::FilePath& file, bool recurse); diff --git a/base/test/test_file_util_posix.cc b/base/test/test_file_util_posix.cc index aa3e9a0..10701be 100644 --- a/base/test/test_file_util_posix.cc +++ b/base/test/test_file_util_posix.cc @@ -77,7 +77,7 @@ bool RestorePermissionInfo(const base::FilePath& path, bool DieFileDie(const base::FilePath& file, bool recurse) { // There is no need to workaround Windows problems on POSIX. // Just pass-through. - return file_util::Delete(file, recurse); + return base::Delete(file, recurse); } #if !defined(OS_LINUX) && !defined(OS_MACOSX) diff --git a/base/test/test_file_util_win.cc b/base/test/test_file_util_win.cc index 8e130d8..9e3697b 100644 --- a/base/test/test_file_util_win.cc +++ b/base/test/test_file_util_win.cc @@ -126,7 +126,7 @@ bool DieFileDie(const base::FilePath& file, bool recurse) { // into short chunks, so that if a try succeeds, we won't delay the test // for too long. for (int i = 0; i < kIterations; ++i) { - if (file_util::Delete(file, recurse)) + if (base::Delete(file, recurse)) return true; base::PlatformThread::Sleep(kTimeout); } diff --git a/base/win/event_trace_consumer_unittest.cc b/base/win/event_trace_consumer_unittest.cc index dbf6eed..b92bdc0 100644 --- a/base/win/event_trace_consumer_unittest.cc +++ b/base/win/event_trace_consumer_unittest.cc @@ -291,7 +291,7 @@ class EtwTraceConsumerDataTest: public EtwTraceConsumerBaseTest { } virtual void TearDown() { - EXPECT_TRUE(file_util::Delete(temp_file_, false)); + EXPECT_TRUE(base::Delete(temp_file_, false)); EtwTraceConsumerBaseTest::TearDown(); } @@ -335,7 +335,7 @@ class EtwTraceConsumerDataTest: public EtwTraceConsumerBaseTest { } HRESULT RoundTripEvent(PEVENT_TRACE_HEADER header, PEVENT_TRACE* trace) { - file_util::Delete(temp_file_, false); + base::Delete(temp_file_, false); HRESULT hr = LogEventToTempSession(header); if (SUCCEEDED(hr)) diff --git a/base/win/event_trace_controller_unittest.cc b/base/win/event_trace_controller_unittest.cc index 7b2e99e..4fe32c3 100644 --- a/base/win/event_trace_controller_unittest.cc +++ b/base/win/event_trace_controller_unittest.cc @@ -171,7 +171,7 @@ TEST_F(EtwTraceControllerTest, StartFileSession) { temp.value().c_str()); if (hr == E_ACCESSDENIED) { VLOG(1) << "You must be an administrator to run this test on Vista"; - file_util::Delete(temp, false); + base::Delete(temp, false); return; } @@ -181,7 +181,7 @@ TEST_F(EtwTraceControllerTest, StartFileSession) { EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); EXPECT_EQ(NULL, controller.session()); EXPECT_STREQ(L"", controller.session_name()); - file_util::Delete(temp, false); + base::Delete(temp, false); } TEST_F(EtwTraceControllerTest, EnableDisable) { |