diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-11 17:36:07 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-11 17:36:07 +0000 |
commit | 7567484144da059e2c2c2a818b06660a5459052f (patch) | |
tree | a4ceafc7e890051c25dbdd54b170d0f5794dd229 /base | |
parent | 8a25d54d6eb190a8b82479b5309a892c1080a372 (diff) | |
download | chromium_src-7567484144da059e2c2c2a818b06660a5459052f.zip chromium_src-7567484144da059e2c2c2a818b06660a5459052f.tar.gz chromium_src-7567484144da059e2c2c2a818b06660a5459052f.tar.bz2 |
Move PathExists to base namespace.
BUG=
TBR=jam@chromium.org
Review URL: https://codereview.chromium.org/18286004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211147 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
27 files changed, 257 insertions, 258 deletions
diff --git a/base/android/path_utils_unittest.cc b/base/android/path_utils_unittest.cc index 52b1928..c4c12fe 100644 --- a/base/android/path_utils_unittest.cc +++ b/base/android/path_utils_unittest.cc @@ -39,7 +39,7 @@ TEST_F(PathUtilsTest, TestGetNativeLibraryDirectory) { // the base tests shared object. FilePath path; GetNativeLibraryDirectory(&path); - EXPECT_TRUE(file_util::PathExists(path.Append(("libbase_unittests.so")))); + EXPECT_TRUE(base::PathExists(path.Append(("libbase_unittests.so")))); } } // namespace android diff --git a/base/base_paths.cc b/base/base_paths.cc index b90efba..9f2b250 100644 --- a/base/base_paths.cc +++ b/base/base_paths.cc @@ -33,7 +33,7 @@ bool PathProvider(int key, FilePath* result) { cur = cur.Append(FILE_PATH_LITERAL("base")); cur = cur.Append(FILE_PATH_LITERAL("test")); cur = cur.Append(FILE_PATH_LITERAL("data")); - if (!file_util::PathExists(cur)) // We don't want to create this. + if (!base::PathExists(cur)) // We don't want to create this. return false; break; default: diff --git a/base/base_paths_mac.mm b/base/base_paths_mac.mm index 1e8bac8..a1121aa 100644 --- a/base/base_paths_mac.mm +++ b/base/base_paths_mac.mm @@ -65,7 +65,7 @@ bool PathProviderMac(int key, base::FilePath* result) { result); #if defined(OS_IOS) // On IOS, this directory does not exist unless it is created explicitly. - if (success && !file_util::PathExists(*result)) + if (success && !base::PathExists(*result)) success = file_util::CreateDirectory(*result); #endif // defined(OS_IOS) return success; diff --git a/base/base_paths_posix.cc b/base/base_paths_posix.cc index 59be094..6d7b5e1 100644 --- a/base/base_paths_posix.cc +++ b/base/base_paths_posix.cc @@ -80,7 +80,7 @@ bool PathProviderPosix(int key, FilePath* result) { std::string cr_source_root; if (env->GetVar("CR_SOURCE_ROOT", &cr_source_root)) { path = FilePath(cr_source_root); - if (file_util::PathExists(path)) { + if (base::PathExists(path)) { *result = path; return true; } else { diff --git a/base/file_util.h b/base/file_util.h index 321070f..095734b 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -112,16 +112,16 @@ BASE_EXPORT bool CopyDirectory(const FilePath& from_path, const FilePath& to_path, bool recursive); +// Returns true if the given path exists on the local filesystem, +// false otherwise. +BASE_EXPORT bool PathExists(const FilePath& path); + } // namespace base // ----------------------------------------------------------------------------- namespace file_util { -// Returns true if the given path exists on the local filesystem, -// false otherwise. -BASE_EXPORT bool PathExists(const base::FilePath& path); - // Returns true if the given path is writable by the user, false otherwise. BASE_EXPORT bool PathIsWritable(const base::FilePath& path); diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index 018a48d..f438253 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -227,7 +227,7 @@ bool CopyDirectory(const FilePath& from_path, // This function does not properly handle destinations within the source FilePath real_to_path = to_path; - if (file_util::PathExists(real_to_path)) { + if (PathExists(real_to_path)) { real_to_path = MakeAbsoluteFilePath(real_to_path); if (real_to_path.empty()) return false; @@ -309,6 +309,11 @@ bool CopyDirectory(const FilePath& from_path, return success; } +bool PathExists(const FilePath& path) { + ThreadRestrictions::AssertIOAllowed(); + return access(path.value().c_str(), F_OK) == 0; +} + } // namespace base // ----------------------------------------------------------------------------- @@ -324,11 +329,6 @@ using base::MakeAbsoluteFilePath; using base::RealPath; using base::VerifySpecificPathControlledByUser; -bool PathExists(const FilePath& path) { - base::ThreadRestrictions::AssertIOAllowed(); - return access(path.value().c_str(), F_OK) == 0; -} - bool PathIsWritable(const FilePath& path) { base::ThreadRestrictions::AssertIOAllowed(); return access(path.value().c_str(), W_OK) == 0; diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc index 5576548..c73d079 100644 --- a/base/file_util_unittest.cc +++ b/base/file_util_unittest.cc @@ -349,18 +349,18 @@ TEST_F(FileUtilTest, NormalizeFilePathBasic) { file_util::CreateDirectory(dir_path); FilePath normalized_file_a_path, normalized_file_b_path; - ASSERT_FALSE(file_util::PathExists(file_a_path)); + ASSERT_FALSE(base::PathExists(file_a_path)); ASSERT_FALSE(file_util::NormalizeFilePath(file_a_path, &normalized_file_a_path)) << "NormalizeFilePath() should fail on nonexistent paths."; CreateTextFile(file_a_path, bogus_content); - ASSERT_TRUE(file_util::PathExists(file_a_path)); + ASSERT_TRUE(base::PathExists(file_a_path)); ASSERT_TRUE(file_util::NormalizeFilePath(file_a_path, &normalized_file_a_path)); CreateTextFile(file_b_path, bogus_content); - ASSERT_TRUE(file_util::PathExists(file_b_path)); + ASSERT_TRUE(base::PathExists(file_b_path)); ASSERT_TRUE(file_util::NormalizeFilePath(file_b_path, &normalized_file_b_path)); @@ -626,7 +626,7 @@ TEST_F(FileUtilTest, CreateTemporaryFileInDirLongPathTest) { FilePath temp_file; ASSERT_TRUE(file_util::CreateTemporaryFileInDir(short_test_dir, &temp_file)); EXPECT_STREQ(kLongDirName, temp_file.DirName().BaseName().value().c_str()); - EXPECT_TRUE(file_util::PathExists(temp_file)); + EXPECT_TRUE(base::PathExists(temp_file)); // Create a subdirectory of |long_test_dir| and make |long_test_dir| // unreadable. We should still be able to create a temp file in the @@ -643,7 +643,7 @@ TEST_F(FileUtilTest, CreateTemporaryFileInDirLongPathTest) { // Use the short form of the directory to create a temporary filename. ASSERT_TRUE(file_util::CreateTemporaryFileInDir( short_test_dir.Append(kTestSubDirName), &temp_file)); - EXPECT_TRUE(file_util::PathExists(temp_file)); + EXPECT_TRUE(base::PathExists(temp_file)); EXPECT_TRUE(short_test_dir.IsParent(temp_file.DirName())); // Check that the long path can't be determined for |temp_file|. @@ -733,32 +733,32 @@ TEST_F(FileUtilTest, NormalizeFilePathSymlinks) { TEST_F(FileUtilTest, DeleteNonExistent) { FilePath non_existent = temp_dir_.path().AppendASCII("bogus_file_dne.foobar"); - ASSERT_FALSE(file_util::PathExists(non_existent)); + ASSERT_FALSE(base::PathExists(non_existent)); EXPECT_TRUE(base::Delete(non_existent, false)); - ASSERT_FALSE(file_util::PathExists(non_existent)); + ASSERT_FALSE(base::PathExists(non_existent)); EXPECT_TRUE(base::Delete(non_existent, true)); - ASSERT_FALSE(file_util::PathExists(non_existent)); + ASSERT_FALSE(base::PathExists(non_existent)); } TEST_F(FileUtilTest, DeleteFile) { // Create a file FilePath file_name = temp_dir_.path().Append(FPL("Test DeleteFile 1.txt")); CreateTextFile(file_name, bogus_content); - ASSERT_TRUE(file_util::PathExists(file_name)); + ASSERT_TRUE(base::PathExists(file_name)); // Make sure it's deleted EXPECT_TRUE(base::Delete(file_name, false)); - EXPECT_FALSE(file_util::PathExists(file_name)); + EXPECT_FALSE(base::PathExists(file_name)); // Test recursive case, create a new file file_name = temp_dir_.path().Append(FPL("Test DeleteFile 2.txt")); CreateTextFile(file_name, bogus_content); - ASSERT_TRUE(file_util::PathExists(file_name)); + ASSERT_TRUE(base::PathExists(file_name)); // Make sure it's deleted EXPECT_TRUE(base::Delete(file_name, true)); - EXPECT_FALSE(file_util::PathExists(file_name)); + EXPECT_FALSE(base::PathExists(file_name)); } #if defined(OS_POSIX) @@ -766,7 +766,7 @@ TEST_F(FileUtilTest, DeleteSymlinkToExistentFile) { // Create a file. FilePath file_name = temp_dir_.path().Append(FPL("Test DeleteFile 2.txt")); CreateTextFile(file_name, bogus_content); - ASSERT_TRUE(file_util::PathExists(file_name)); + ASSERT_TRUE(base::PathExists(file_name)); // Create a symlink to the file. FilePath file_link = temp_dir_.path().Append("file_link_2"); @@ -777,14 +777,14 @@ TEST_F(FileUtilTest, DeleteSymlinkToExistentFile) { EXPECT_TRUE(base::Delete(file_link, false)); // Make sure original file is not deleted. - EXPECT_FALSE(file_util::PathExists(file_link)); - EXPECT_TRUE(file_util::PathExists(file_name)); + EXPECT_FALSE(base::PathExists(file_link)); + EXPECT_TRUE(base::PathExists(file_name)); } TEST_F(FileUtilTest, DeleteSymlinkToNonExistentFile) { // Create a non-existent file path. FilePath non_existent = temp_dir_.path().Append(FPL("Test DeleteFile 3.txt")); - EXPECT_FALSE(file_util::PathExists(non_existent)); + EXPECT_FALSE(base::PathExists(non_existent)); // Create a symlink to the non-existent file. FilePath file_link = temp_dir_.path().Append("file_link_3"); @@ -793,7 +793,7 @@ TEST_F(FileUtilTest, DeleteSymlinkToNonExistentFile) { // Make sure the symbolic link is exist. EXPECT_TRUE(file_util::IsLink(file_link)); - EXPECT_FALSE(file_util::PathExists(file_link)); + EXPECT_FALSE(base::PathExists(file_link)); // Delete the symbolic link. EXPECT_TRUE(base::Delete(file_link, false)); @@ -805,7 +805,7 @@ TEST_F(FileUtilTest, DeleteSymlinkToNonExistentFile) { TEST_F(FileUtilTest, ChangeFilePermissionsAndRead) { // Create a file path. FilePath file_name = temp_dir_.path().Append(FPL("Test Readable File.txt")); - EXPECT_FALSE(file_util::PathExists(file_name)); + EXPECT_FALSE(base::PathExists(file_name)); const std::string kData("hello"); @@ -815,7 +815,7 @@ TEST_F(FileUtilTest, ChangeFilePermissionsAndRead) { // Write file. EXPECT_EQ(static_cast<int>(kData.length()), file_util::WriteFile(file_name, kData.data(), kData.length())); - EXPECT_TRUE(file_util::PathExists(file_name)); + EXPECT_TRUE(base::PathExists(file_name)); // Make sure the file is readable. int32 mode = 0; @@ -841,7 +841,7 @@ TEST_F(FileUtilTest, ChangeFilePermissionsAndRead) { // Delete the file. EXPECT_TRUE(base::Delete(file_name, false)); - EXPECT_FALSE(file_util::PathExists(file_name)); + EXPECT_FALSE(base::PathExists(file_name)); delete[] buffer; } @@ -849,14 +849,14 @@ TEST_F(FileUtilTest, ChangeFilePermissionsAndRead) { TEST_F(FileUtilTest, ChangeFilePermissionsAndWrite) { // Create a file path. FilePath file_name = temp_dir_.path().Append(FPL("Test Readable File.txt")); - EXPECT_FALSE(file_util::PathExists(file_name)); + EXPECT_FALSE(base::PathExists(file_name)); const std::string kData("hello"); // Write file. EXPECT_EQ(static_cast<int>(kData.length()), file_util::WriteFile(file_name, kData.data(), kData.length())); - EXPECT_TRUE(file_util::PathExists(file_name)); + EXPECT_TRUE(base::PathExists(file_name)); // Make sure the file is writable. int mode = 0; @@ -886,7 +886,7 @@ TEST_F(FileUtilTest, ChangeFilePermissionsAndWrite) { // Delete the file. EXPECT_TRUE(base::Delete(file_name, false)); - EXPECT_FALSE(file_util::PathExists(file_name)); + EXPECT_FALSE(base::PathExists(file_name)); } TEST_F(FileUtilTest, ChangeDirectoryPermissionsAndEnumerate) { @@ -894,15 +894,15 @@ TEST_F(FileUtilTest, ChangeDirectoryPermissionsAndEnumerate) { FilePath subdir_path = temp_dir_.path().Append(FPL("PermissionTest1")); file_util::CreateDirectory(subdir_path); - ASSERT_TRUE(file_util::PathExists(subdir_path)); + ASSERT_TRUE(base::PathExists(subdir_path)); // Create a dummy file to enumerate. FilePath file_name = subdir_path.Append(FPL("Test Readable File.txt")); - EXPECT_FALSE(file_util::PathExists(file_name)); + EXPECT_FALSE(base::PathExists(file_name)); const std::string kData("hello"); EXPECT_EQ(static_cast<int>(kData.length()), file_util::WriteFile(file_name, kData.data(), kData.length())); - EXPECT_TRUE(file_util::PathExists(file_name)); + EXPECT_TRUE(base::PathExists(file_name)); // Make sure the directory has the all permissions. int mode = 0; @@ -917,7 +917,7 @@ TEST_F(FileUtilTest, ChangeDirectoryPermissionsAndEnumerate) { // Make sure the file in the directory can't be enumerated. FileEnumerator f1(subdir_path, true, FileEnumerator::FILES); - EXPECT_TRUE(file_util::PathExists(subdir_path)); + EXPECT_TRUE(base::PathExists(subdir_path)); FindResultCollector c1(f1); EXPECT_EQ(c1.size(), 0); EXPECT_FALSE(file_util::GetPosixFilePermissions(file_name, &mode)); @@ -938,7 +938,7 @@ TEST_F(FileUtilTest, ChangeDirectoryPermissionsAndEnumerate) { // Delete the file. EXPECT_TRUE(base::Delete(subdir_path, true)); - EXPECT_FALSE(file_util::PathExists(subdir_path)); + EXPECT_FALSE(base::PathExists(subdir_path)); } #endif // defined(OS_POSIX) @@ -951,11 +951,11 @@ TEST_F(FileUtilTest, DeleteWildCard) { // Create a file and a directory FilePath file_name = temp_dir_.path().Append(FPL("Test DeleteWildCard.txt")); CreateTextFile(file_name, bogus_content); - ASSERT_TRUE(file_util::PathExists(file_name)); + ASSERT_TRUE(base::PathExists(file_name)); FilePath subdir_path = temp_dir_.path().Append(FPL("DeleteWildCardDir")); file_util::CreateDirectory(subdir_path); - ASSERT_TRUE(file_util::PathExists(subdir_path)); + ASSERT_TRUE(base::PathExists(subdir_path)); // Create the wildcard path FilePath directory_contents = temp_dir_.path(); @@ -963,13 +963,13 @@ TEST_F(FileUtilTest, DeleteWildCard) { // Delete non-recursively and check that only the file is deleted EXPECT_TRUE(base::Delete(directory_contents, false)); - EXPECT_FALSE(file_util::PathExists(file_name)); - EXPECT_TRUE(file_util::PathExists(subdir_path)); + EXPECT_FALSE(base::PathExists(file_name)); + EXPECT_TRUE(base::PathExists(subdir_path)); // Delete recursively and make sure all contents are deleted EXPECT_TRUE(base::Delete(directory_contents, true)); - EXPECT_FALSE(file_util::PathExists(file_name)); - EXPECT_FALSE(file_util::PathExists(subdir_path)); + EXPECT_FALSE(base::PathExists(file_name)); + EXPECT_FALSE(base::PathExists(subdir_path)); } // TODO(erikkay): see if anyone's actually using this feature of the API @@ -978,7 +978,7 @@ TEST_F(FileUtilTest, DeleteNonExistantWildCard) { FilePath subdir_path = temp_dir_.path().Append(FPL("DeleteNonExistantWildCard")); file_util::CreateDirectory(subdir_path); - ASSERT_TRUE(file_util::PathExists(subdir_path)); + ASSERT_TRUE(base::PathExists(subdir_path)); // Create the wildcard path FilePath directory_contents = subdir_path; @@ -986,11 +986,11 @@ TEST_F(FileUtilTest, DeleteNonExistantWildCard) { // Delete non-recursively and check nothing got deleted EXPECT_TRUE(base::Delete(directory_contents, false)); - EXPECT_TRUE(file_util::PathExists(subdir_path)); + EXPECT_TRUE(base::PathExists(subdir_path)); // Delete recursively and check nothing got deleted EXPECT_TRUE(base::Delete(directory_contents, true)); - EXPECT_TRUE(file_util::PathExists(subdir_path)); + EXPECT_TRUE(base::PathExists(subdir_path)); } #endif @@ -999,29 +999,29 @@ TEST_F(FileUtilTest, DeleteDirNonRecursive) { // Create a subdirectory and put a file and two directories inside. FilePath test_subdir = temp_dir_.path().Append(FPL("DeleteDirNonRecursive")); file_util::CreateDirectory(test_subdir); - ASSERT_TRUE(file_util::PathExists(test_subdir)); + ASSERT_TRUE(base::PathExists(test_subdir)); FilePath file_name = test_subdir.Append(FPL("Test DeleteDir.txt")); CreateTextFile(file_name, bogus_content); - ASSERT_TRUE(file_util::PathExists(file_name)); + ASSERT_TRUE(base::PathExists(file_name)); FilePath subdir_path1 = test_subdir.Append(FPL("TestSubDir1")); file_util::CreateDirectory(subdir_path1); - ASSERT_TRUE(file_util::PathExists(subdir_path1)); + ASSERT_TRUE(base::PathExists(subdir_path1)); FilePath subdir_path2 = test_subdir.Append(FPL("TestSubDir2")); file_util::CreateDirectory(subdir_path2); - ASSERT_TRUE(file_util::PathExists(subdir_path2)); + ASSERT_TRUE(base::PathExists(subdir_path2)); // Delete non-recursively and check that the empty dir got deleted EXPECT_TRUE(base::Delete(subdir_path2, false)); - EXPECT_FALSE(file_util::PathExists(subdir_path2)); + EXPECT_FALSE(base::PathExists(subdir_path2)); // Delete non-recursively and check that nothing got deleted 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)); + EXPECT_TRUE(base::PathExists(test_subdir)); + EXPECT_TRUE(base::PathExists(file_name)); + EXPECT_TRUE(base::PathExists(subdir_path1)); } // Tests recursive Delete() for a directory. @@ -1029,29 +1029,29 @@ TEST_F(FileUtilTest, DeleteDirRecursive) { // Create a subdirectory and put a file and two directories inside. FilePath test_subdir = temp_dir_.path().Append(FPL("DeleteDirRecursive")); file_util::CreateDirectory(test_subdir); - ASSERT_TRUE(file_util::PathExists(test_subdir)); + ASSERT_TRUE(base::PathExists(test_subdir)); FilePath file_name = test_subdir.Append(FPL("Test DeleteDirRecursive.txt")); CreateTextFile(file_name, bogus_content); - ASSERT_TRUE(file_util::PathExists(file_name)); + ASSERT_TRUE(base::PathExists(file_name)); FilePath subdir_path1 = test_subdir.Append(FPL("TestSubDir1")); file_util::CreateDirectory(subdir_path1); - ASSERT_TRUE(file_util::PathExists(subdir_path1)); + ASSERT_TRUE(base::PathExists(subdir_path1)); FilePath subdir_path2 = test_subdir.Append(FPL("TestSubDir2")); file_util::CreateDirectory(subdir_path2); - ASSERT_TRUE(file_util::PathExists(subdir_path2)); + ASSERT_TRUE(base::PathExists(subdir_path2)); // Delete recursively and check that the empty dir got deleted EXPECT_TRUE(base::Delete(subdir_path2, true)); - EXPECT_FALSE(file_util::PathExists(subdir_path2)); + EXPECT_FALSE(base::PathExists(subdir_path2)); // Delete recursively and check that everything got deleted 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)); + EXPECT_FALSE(base::PathExists(file_name)); + EXPECT_FALSE(base::PathExists(subdir_path1)); + EXPECT_FALSE(base::PathExists(test_subdir)); } TEST_F(FileUtilTest, MoveFileNew) { @@ -1059,18 +1059,18 @@ TEST_F(FileUtilTest, MoveFileNew) { FilePath file_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Move_Test_File.txt")); CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // The destination. FilePath file_name_to = temp_dir_.path().Append( FILE_PATH_LITERAL("Move_Test_File_Destination.txt")); - ASSERT_FALSE(file_util::PathExists(file_name_to)); + ASSERT_FALSE(base::PathExists(file_name_to)); EXPECT_TRUE(base::Move(file_name_from, file_name_to)); // Check everything has been moved. - EXPECT_FALSE(file_util::PathExists(file_name_from)); - EXPECT_TRUE(file_util::PathExists(file_name_to)); + EXPECT_FALSE(base::PathExists(file_name_from)); + EXPECT_TRUE(base::PathExists(file_name_to)); } TEST_F(FileUtilTest, MoveFileExists) { @@ -1078,19 +1078,19 @@ TEST_F(FileUtilTest, MoveFileExists) { FilePath file_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Move_Test_File.txt")); CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // The destination name. FilePath file_name_to = temp_dir_.path().Append( FILE_PATH_LITERAL("Move_Test_File_Destination.txt")); CreateTextFile(file_name_to, L"Old file content"); - ASSERT_TRUE(file_util::PathExists(file_name_to)); + ASSERT_TRUE(base::PathExists(file_name_to)); EXPECT_TRUE(base::Move(file_name_from, file_name_to)); // Check everything has been moved. - EXPECT_FALSE(file_util::PathExists(file_name_from)); - EXPECT_TRUE(file_util::PathExists(file_name_to)); + EXPECT_FALSE(base::PathExists(file_name_from)); + EXPECT_TRUE(base::PathExists(file_name_to)); EXPECT_TRUE(L"Gooooooooooooooooooooogle" == ReadTextFile(file_name_to)); } @@ -1099,13 +1099,13 @@ TEST_F(FileUtilTest, MoveFileDirExists) { FilePath file_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Move_Test_File.txt")); CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // The destination directory FilePath dir_name_to = temp_dir_.path().Append(FILE_PATH_LITERAL("Destination")); file_util::CreateDirectory(dir_name_to); - ASSERT_TRUE(file_util::PathExists(dir_name_to)); + ASSERT_TRUE(base::PathExists(dir_name_to)); EXPECT_FALSE(base::Move(file_name_from, dir_name_to)); } @@ -1116,13 +1116,13 @@ TEST_F(FileUtilTest, MoveNew) { FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Move_From_Subdir")); file_util::CreateDirectory(dir_name_from); - ASSERT_TRUE(file_util::PathExists(dir_name_from)); + ASSERT_TRUE(base::PathExists(dir_name_from)); // Create a file under the directory FilePath txt_file_name(FILE_PATH_LITERAL("Move_Test_File.txt")); FilePath file_name_from = dir_name_from.Append(txt_file_name); CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // Move the directory. FilePath dir_name_to = @@ -1130,26 +1130,26 @@ TEST_F(FileUtilTest, MoveNew) { FilePath file_name_to = dir_name_to.Append(FILE_PATH_LITERAL("Move_Test_File.txt")); - ASSERT_FALSE(file_util::PathExists(dir_name_to)); + ASSERT_FALSE(base::PathExists(dir_name_to)); EXPECT_TRUE(base::Move(dir_name_from, dir_name_to)); // Check everything has been moved. - EXPECT_FALSE(file_util::PathExists(dir_name_from)); - EXPECT_FALSE(file_util::PathExists(file_name_from)); - EXPECT_TRUE(file_util::PathExists(dir_name_to)); - EXPECT_TRUE(file_util::PathExists(file_name_to)); + EXPECT_FALSE(base::PathExists(dir_name_from)); + EXPECT_FALSE(base::PathExists(file_name_from)); + EXPECT_TRUE(base::PathExists(dir_name_to)); + EXPECT_TRUE(base::PathExists(file_name_to)); // Test path traversal. file_name_from = dir_name_to.Append(txt_file_name); file_name_to = dir_name_to.Append(FILE_PATH_LITERAL("..")); file_name_to = file_name_to.Append(txt_file_name); EXPECT_FALSE(base::Move(file_name_from, file_name_to)); - EXPECT_TRUE(file_util::PathExists(file_name_from)); - EXPECT_FALSE(file_util::PathExists(file_name_to)); + EXPECT_TRUE(base::PathExists(file_name_from)); + EXPECT_FALSE(base::PathExists(file_name_to)); EXPECT_TRUE(base::internal::MoveUnsafe(file_name_from, file_name_to)); - EXPECT_FALSE(file_util::PathExists(file_name_from)); - EXPECT_TRUE(file_util::PathExists(file_name_to)); + EXPECT_FALSE(base::PathExists(file_name_from)); + EXPECT_TRUE(base::PathExists(file_name_to)); } TEST_F(FileUtilTest, MoveExist) { @@ -1157,13 +1157,13 @@ TEST_F(FileUtilTest, MoveExist) { FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Move_From_Subdir")); file_util::CreateDirectory(dir_name_from); - ASSERT_TRUE(file_util::PathExists(dir_name_from)); + ASSERT_TRUE(base::PathExists(dir_name_from)); // Create a file under the directory FilePath file_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Move_Test_File.txt")); CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // Move the directory FilePath dir_name_exists = @@ -1176,15 +1176,15 @@ TEST_F(FileUtilTest, MoveExist) { // Create the destination directory. file_util::CreateDirectory(dir_name_exists); - ASSERT_TRUE(file_util::PathExists(dir_name_exists)); + ASSERT_TRUE(base::PathExists(dir_name_exists)); EXPECT_TRUE(base::Move(dir_name_from, dir_name_to)); // Check everything has been moved. - EXPECT_FALSE(file_util::PathExists(dir_name_from)); - EXPECT_FALSE(file_util::PathExists(file_name_from)); - EXPECT_TRUE(file_util::PathExists(dir_name_to)); - EXPECT_TRUE(file_util::PathExists(file_name_to)); + EXPECT_FALSE(base::PathExists(dir_name_from)); + EXPECT_FALSE(base::PathExists(file_name_from)); + EXPECT_TRUE(base::PathExists(dir_name_to)); + EXPECT_TRUE(base::PathExists(file_name_to)); } TEST_F(FileUtilTest, CopyDirectoryRecursivelyNew) { @@ -1192,25 +1192,25 @@ TEST_F(FileUtilTest, CopyDirectoryRecursivelyNew) { FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); file_util::CreateDirectory(dir_name_from); - ASSERT_TRUE(file_util::PathExists(dir_name_from)); + ASSERT_TRUE(base::PathExists(dir_name_from)); // Create a file under the directory. FilePath file_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // Create a subdirectory. FilePath subdir_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Subdir")); file_util::CreateDirectory(subdir_name_from); - ASSERT_TRUE(file_util::PathExists(subdir_name_from)); + ASSERT_TRUE(base::PathExists(subdir_name_from)); // Create a file under the subdirectory. FilePath file_name2_from = subdir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); CreateTextFile(file_name2_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name2_from)); + ASSERT_TRUE(base::PathExists(file_name2_from)); // Copy the directory recursively. FilePath dir_name_to = @@ -1222,19 +1222,19 @@ TEST_F(FileUtilTest, CopyDirectoryRecursivelyNew) { FilePath file_name2_to = subdir_name_to.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); - ASSERT_FALSE(file_util::PathExists(dir_name_to)); + ASSERT_FALSE(base::PathExists(dir_name_to)); EXPECT_TRUE(base::CopyDirectory(dir_name_from, dir_name_to, true)); // Check everything has been copied. - EXPECT_TRUE(file_util::PathExists(dir_name_from)); - EXPECT_TRUE(file_util::PathExists(file_name_from)); - EXPECT_TRUE(file_util::PathExists(subdir_name_from)); - EXPECT_TRUE(file_util::PathExists(file_name2_from)); - EXPECT_TRUE(file_util::PathExists(dir_name_to)); - EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_TRUE(file_util::PathExists(subdir_name_to)); - EXPECT_TRUE(file_util::PathExists(file_name2_to)); + EXPECT_TRUE(base::PathExists(dir_name_from)); + EXPECT_TRUE(base::PathExists(file_name_from)); + EXPECT_TRUE(base::PathExists(subdir_name_from)); + EXPECT_TRUE(base::PathExists(file_name2_from)); + EXPECT_TRUE(base::PathExists(dir_name_to)); + EXPECT_TRUE(base::PathExists(file_name_to)); + EXPECT_TRUE(base::PathExists(subdir_name_to)); + EXPECT_TRUE(base::PathExists(file_name2_to)); } TEST_F(FileUtilTest, CopyDirectoryRecursivelyExists) { @@ -1242,25 +1242,25 @@ TEST_F(FileUtilTest, CopyDirectoryRecursivelyExists) { FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); file_util::CreateDirectory(dir_name_from); - ASSERT_TRUE(file_util::PathExists(dir_name_from)); + ASSERT_TRUE(base::PathExists(dir_name_from)); // Create a file under the directory. FilePath file_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // Create a subdirectory. FilePath subdir_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Subdir")); file_util::CreateDirectory(subdir_name_from); - ASSERT_TRUE(file_util::PathExists(subdir_name_from)); + ASSERT_TRUE(base::PathExists(subdir_name_from)); // Create a file under the subdirectory. FilePath file_name2_from = subdir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); CreateTextFile(file_name2_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name2_from)); + ASSERT_TRUE(base::PathExists(file_name2_from)); // Copy the directory recursively. FilePath dir_name_exists = @@ -1277,19 +1277,19 @@ TEST_F(FileUtilTest, CopyDirectoryRecursivelyExists) { // Create the destination directory. file_util::CreateDirectory(dir_name_exists); - ASSERT_TRUE(file_util::PathExists(dir_name_exists)); + ASSERT_TRUE(base::PathExists(dir_name_exists)); EXPECT_TRUE(base::CopyDirectory(dir_name_from, dir_name_exists, true)); // Check everything has been copied. - EXPECT_TRUE(file_util::PathExists(dir_name_from)); - EXPECT_TRUE(file_util::PathExists(file_name_from)); - EXPECT_TRUE(file_util::PathExists(subdir_name_from)); - EXPECT_TRUE(file_util::PathExists(file_name2_from)); - EXPECT_TRUE(file_util::PathExists(dir_name_to)); - EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_TRUE(file_util::PathExists(subdir_name_to)); - EXPECT_TRUE(file_util::PathExists(file_name2_to)); + EXPECT_TRUE(base::PathExists(dir_name_from)); + EXPECT_TRUE(base::PathExists(file_name_from)); + EXPECT_TRUE(base::PathExists(subdir_name_from)); + EXPECT_TRUE(base::PathExists(file_name2_from)); + EXPECT_TRUE(base::PathExists(dir_name_to)); + EXPECT_TRUE(base::PathExists(file_name_to)); + EXPECT_TRUE(base::PathExists(subdir_name_to)); + EXPECT_TRUE(base::PathExists(file_name2_to)); } TEST_F(FileUtilTest, CopyDirectoryNew) { @@ -1297,25 +1297,25 @@ TEST_F(FileUtilTest, CopyDirectoryNew) { FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); file_util::CreateDirectory(dir_name_from); - ASSERT_TRUE(file_util::PathExists(dir_name_from)); + ASSERT_TRUE(base::PathExists(dir_name_from)); // Create a file under the directory. FilePath file_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // Create a subdirectory. FilePath subdir_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Subdir")); file_util::CreateDirectory(subdir_name_from); - ASSERT_TRUE(file_util::PathExists(subdir_name_from)); + ASSERT_TRUE(base::PathExists(subdir_name_from)); // Create a file under the subdirectory. FilePath file_name2_from = subdir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); CreateTextFile(file_name2_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name2_from)); + ASSERT_TRUE(base::PathExists(file_name2_from)); // Copy the directory not recursively. FilePath dir_name_to = @@ -1325,18 +1325,18 @@ TEST_F(FileUtilTest, CopyDirectoryNew) { FilePath subdir_name_to = dir_name_to.Append(FILE_PATH_LITERAL("Subdir")); - ASSERT_FALSE(file_util::PathExists(dir_name_to)); + ASSERT_FALSE(base::PathExists(dir_name_to)); EXPECT_TRUE(base::CopyDirectory(dir_name_from, dir_name_to, false)); // Check everything has been copied. - EXPECT_TRUE(file_util::PathExists(dir_name_from)); - EXPECT_TRUE(file_util::PathExists(file_name_from)); - EXPECT_TRUE(file_util::PathExists(subdir_name_from)); - EXPECT_TRUE(file_util::PathExists(file_name2_from)); - EXPECT_TRUE(file_util::PathExists(dir_name_to)); - EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_FALSE(file_util::PathExists(subdir_name_to)); + EXPECT_TRUE(base::PathExists(dir_name_from)); + EXPECT_TRUE(base::PathExists(file_name_from)); + EXPECT_TRUE(base::PathExists(subdir_name_from)); + EXPECT_TRUE(base::PathExists(file_name2_from)); + EXPECT_TRUE(base::PathExists(dir_name_to)); + EXPECT_TRUE(base::PathExists(file_name_to)); + EXPECT_FALSE(base::PathExists(subdir_name_to)); } TEST_F(FileUtilTest, CopyDirectoryExists) { @@ -1344,25 +1344,25 @@ TEST_F(FileUtilTest, CopyDirectoryExists) { FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); file_util::CreateDirectory(dir_name_from); - ASSERT_TRUE(file_util::PathExists(dir_name_from)); + ASSERT_TRUE(base::PathExists(dir_name_from)); // Create a file under the directory. FilePath file_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // Create a subdirectory. FilePath subdir_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Subdir")); file_util::CreateDirectory(subdir_name_from); - ASSERT_TRUE(file_util::PathExists(subdir_name_from)); + ASSERT_TRUE(base::PathExists(subdir_name_from)); // Create a file under the subdirectory. FilePath file_name2_from = subdir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); CreateTextFile(file_name2_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name2_from)); + ASSERT_TRUE(base::PathExists(file_name2_from)); // Copy the directory not recursively. FilePath dir_name_to = @@ -1374,18 +1374,18 @@ TEST_F(FileUtilTest, CopyDirectoryExists) { // Create the destination directory. file_util::CreateDirectory(dir_name_to); - ASSERT_TRUE(file_util::PathExists(dir_name_to)); + ASSERT_TRUE(base::PathExists(dir_name_to)); EXPECT_TRUE(base::CopyDirectory(dir_name_from, dir_name_to, false)); // Check everything has been copied. - EXPECT_TRUE(file_util::PathExists(dir_name_from)); - EXPECT_TRUE(file_util::PathExists(file_name_from)); - EXPECT_TRUE(file_util::PathExists(subdir_name_from)); - EXPECT_TRUE(file_util::PathExists(file_name2_from)); - EXPECT_TRUE(file_util::PathExists(dir_name_to)); - EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_FALSE(file_util::PathExists(subdir_name_to)); + EXPECT_TRUE(base::PathExists(dir_name_from)); + EXPECT_TRUE(base::PathExists(file_name_from)); + EXPECT_TRUE(base::PathExists(subdir_name_from)); + EXPECT_TRUE(base::PathExists(file_name2_from)); + EXPECT_TRUE(base::PathExists(dir_name_to)); + EXPECT_TRUE(base::PathExists(file_name_to)); + EXPECT_FALSE(base::PathExists(subdir_name_to)); } TEST_F(FileUtilTest, CopyFileWithCopyDirectoryRecursiveToNew) { @@ -1393,17 +1393,17 @@ TEST_F(FileUtilTest, CopyFileWithCopyDirectoryRecursiveToNew) { FilePath file_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // The destination name FilePath file_name_to = temp_dir_.path().Append( FILE_PATH_LITERAL("Copy_Test_File_Destination.txt")); - ASSERT_FALSE(file_util::PathExists(file_name_to)); + ASSERT_FALSE(base::PathExists(file_name_to)); EXPECT_TRUE(base::CopyDirectory(file_name_from, file_name_to, true)); // Check the has been copied - EXPECT_TRUE(file_util::PathExists(file_name_to)); + EXPECT_TRUE(base::PathExists(file_name_to)); } TEST_F(FileUtilTest, CopyFileWithCopyDirectoryRecursiveToExisting) { @@ -1411,18 +1411,18 @@ TEST_F(FileUtilTest, CopyFileWithCopyDirectoryRecursiveToExisting) { FilePath file_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // The destination name FilePath file_name_to = temp_dir_.path().Append( FILE_PATH_LITERAL("Copy_Test_File_Destination.txt")); CreateTextFile(file_name_to, L"Old file content"); - ASSERT_TRUE(file_util::PathExists(file_name_to)); + ASSERT_TRUE(base::PathExists(file_name_to)); EXPECT_TRUE(base::CopyDirectory(file_name_from, file_name_to, true)); // Check the has been copied - EXPECT_TRUE(file_util::PathExists(file_name_to)); + EXPECT_TRUE(base::PathExists(file_name_to)); EXPECT_TRUE(L"Gooooooooooooooooooooogle" == ReadTextFile(file_name_to)); } @@ -1431,20 +1431,20 @@ TEST_F(FileUtilTest, CopyFileWithCopyDirectoryRecursiveToExistingDirectory) { FilePath file_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // The destination FilePath dir_name_to = temp_dir_.path().Append(FILE_PATH_LITERAL("Destination")); file_util::CreateDirectory(dir_name_to); - ASSERT_TRUE(file_util::PathExists(dir_name_to)); + ASSERT_TRUE(base::PathExists(dir_name_to)); FilePath file_name_to = dir_name_to.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); EXPECT_TRUE(base::CopyDirectory(file_name_from, dir_name_to, true)); // Check the has been copied - EXPECT_TRUE(file_util::PathExists(file_name_to)); + EXPECT_TRUE(base::PathExists(file_name_to)); } TEST_F(FileUtilTest, CopyDirectoryWithTrailingSeparators) { @@ -1452,13 +1452,13 @@ TEST_F(FileUtilTest, CopyDirectoryWithTrailingSeparators) { FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); file_util::CreateDirectory(dir_name_from); - ASSERT_TRUE(file_util::PathExists(dir_name_from)); + ASSERT_TRUE(base::PathExists(dir_name_from)); // Create a file under the directory. FilePath file_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // Copy the directory recursively. FilePath dir_name_to = @@ -1478,10 +1478,10 @@ TEST_F(FileUtilTest, CopyDirectoryWithTrailingSeparators) { EXPECT_TRUE(base::CopyDirectory(from_path, dir_name_to, true)); // Check everything has been copied. - EXPECT_TRUE(file_util::PathExists(dir_name_from)); - EXPECT_TRUE(file_util::PathExists(file_name_from)); - EXPECT_TRUE(file_util::PathExists(dir_name_to)); - EXPECT_TRUE(file_util::PathExists(file_name_to)); + EXPECT_TRUE(base::PathExists(dir_name_from)); + EXPECT_TRUE(base::PathExists(file_name_from)); + EXPECT_TRUE(base::PathExists(dir_name_to)); + EXPECT_TRUE(base::PathExists(file_name_to)); } TEST_F(FileUtilTest, CopyFile) { @@ -1489,14 +1489,14 @@ TEST_F(FileUtilTest, CopyFile) { FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); file_util::CreateDirectory(dir_name_from); - ASSERT_TRUE(file_util::PathExists(dir_name_from)); + ASSERT_TRUE(base::PathExists(dir_name_from)); // Create a file under the directory FilePath file_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); const std::wstring file_contents(L"Gooooooooooooooooooooogle"); CreateTextFile(file_name_from, file_contents); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // Copy the file. FilePath dest_file = dir_name_from.Append(FILE_PATH_LITERAL("DestFile.txt")); @@ -1514,12 +1514,12 @@ TEST_F(FileUtilTest, CopyFile) { dest_file2_test = dest_file2_test.AppendASCII("DestFile.txt"); // Check everything has been copied. - EXPECT_TRUE(file_util::PathExists(file_name_from)); - EXPECT_TRUE(file_util::PathExists(dest_file)); + EXPECT_TRUE(base::PathExists(file_name_from)); + EXPECT_TRUE(base::PathExists(dest_file)); const std::wstring read_contents = ReadTextFile(dest_file); EXPECT_EQ(file_contents, read_contents); - EXPECT_TRUE(file_util::PathExists(dest_file2_test)); - EXPECT_TRUE(file_util::PathExists(dest_file2)); + EXPECT_TRUE(base::PathExists(dest_file2_test)); + EXPECT_TRUE(base::PathExists(dest_file2)); } // file_util winds up using autoreleased objects on the Mac, so this needs @@ -1530,7 +1530,7 @@ TEST_F(ReadOnlyFileUtilTest, ContentsEqual) { FilePath data_dir; ASSERT_TRUE(PathService::Get(base::DIR_TEST_DATA, &data_dir)); data_dir = data_dir.AppendASCII("file_util"); - ASSERT_TRUE(file_util::PathExists(data_dir)); + ASSERT_TRUE(base::PathExists(data_dir)); FilePath original_file = data_dir.Append(FILE_PATH_LITERAL("original.txt")); @@ -1577,7 +1577,7 @@ TEST_F(ReadOnlyFileUtilTest, TextContentsEqual) { FilePath data_dir; ASSERT_TRUE(PathService::Get(base::DIR_TEST_DATA, &data_dir)); data_dir = data_dir.AppendASCII("file_util"); - ASSERT_TRUE(file_util::PathExists(data_dir)); + ASSERT_TRUE(base::PathExists(data_dir)); FilePath original_file = data_dir.Append(FILE_PATH_LITERAL("original.txt")); @@ -1628,13 +1628,13 @@ TEST_F(FileUtilTest, CopyAndDeleteDirectoryTest) { FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("CopyAndDelete_From_Subdir")); file_util::CreateDirectory(dir_name_from); - ASSERT_TRUE(file_util::PathExists(dir_name_from)); + ASSERT_TRUE(base::PathExists(dir_name_from)); // Create a file under the directory FilePath file_name_from = dir_name_from.Append(FILE_PATH_LITERAL("CopyAndDelete_Test_File.txt")); CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); - ASSERT_TRUE(file_util::PathExists(file_name_from)); + ASSERT_TRUE(base::PathExists(file_name_from)); // Move the directory by using CopyAndDeleteDirectory FilePath dir_name_to = temp_dir_.path().Append( @@ -1642,16 +1642,16 @@ TEST_F(FileUtilTest, CopyAndDeleteDirectoryTest) { FilePath file_name_to = dir_name_to.Append(FILE_PATH_LITERAL("CopyAndDelete_Test_File.txt")); - ASSERT_FALSE(file_util::PathExists(dir_name_to)); + ASSERT_FALSE(base::PathExists(dir_name_to)); EXPECT_TRUE(base::internal::CopyAndDeleteDirectory(dir_name_from, dir_name_to)); // Check everything has been moved. - EXPECT_FALSE(file_util::PathExists(dir_name_from)); - EXPECT_FALSE(file_util::PathExists(file_name_from)); - EXPECT_TRUE(file_util::PathExists(dir_name_to)); - EXPECT_TRUE(file_util::PathExists(file_name_to)); + EXPECT_FALSE(base::PathExists(dir_name_from)); + EXPECT_FALSE(base::PathExists(file_name_from)); + EXPECT_TRUE(base::PathExists(dir_name_to)); + EXPECT_TRUE(base::PathExists(file_name_to)); } TEST_F(FileUtilTest, GetTempDirTest) { @@ -1687,7 +1687,7 @@ TEST_F(FileUtilTest, CreateTemporaryFileTest) { FilePath temp_files[3]; for (int i = 0; i < 3; i++) { ASSERT_TRUE(file_util::CreateTemporaryFile(&(temp_files[i]))); - EXPECT_TRUE(file_util::PathExists(temp_files[i])); + EXPECT_TRUE(base::PathExists(temp_files[i])); EXPECT_FALSE(file_util::DirectoryExists(temp_files[i])); } for (int i = 0; i < 3; i++) @@ -1705,7 +1705,7 @@ TEST_F(FileUtilTest, CreateAndOpenTemporaryFileTest) { for (i = 0; i < 3; ++i) { fps[i] = file_util::CreateAndOpenTemporaryFile(&(names[i])); ASSERT_TRUE(fps[i]); - EXPECT_TRUE(file_util::PathExists(names[i])); + EXPECT_TRUE(base::PathExists(names[i])); } // Make sure all names are unique. @@ -1724,7 +1724,7 @@ TEST_F(FileUtilTest, CreateNewTempDirectoryTest) { FilePath temp_dir; ASSERT_TRUE(file_util::CreateNewTempDirectory(FilePath::StringType(), &temp_dir)); - EXPECT_TRUE(file_util::PathExists(temp_dir)); + EXPECT_TRUE(base::PathExists(temp_dir)); EXPECT_TRUE(base::Delete(temp_dir, false)); } @@ -1734,7 +1734,7 @@ TEST_F(FileUtilTest, CreateNewTemporaryDirInDirTest) { temp_dir_.path(), FILE_PATH_LITERAL("CreateNewTemporaryDirInDirTest"), &new_dir)); - EXPECT_TRUE(file_util::PathExists(new_dir)); + EXPECT_TRUE(base::PathExists(new_dir)); EXPECT_TRUE(temp_dir_.path().IsParent(new_dir)); EXPECT_TRUE(base::Delete(new_dir, false)); } @@ -1756,22 +1756,22 @@ TEST_F(FileUtilTest, CreateDirectoryTest) { test_root.Append(FILE_PATH_LITERAL("dir/tree/likely/doesnt/exist/")); #endif - EXPECT_FALSE(file_util::PathExists(test_path)); + EXPECT_FALSE(base::PathExists(test_path)); EXPECT_TRUE(file_util::CreateDirectory(test_path)); - EXPECT_TRUE(file_util::PathExists(test_path)); + EXPECT_TRUE(base::PathExists(test_path)); // CreateDirectory returns true if the DirectoryExists returns true. EXPECT_TRUE(file_util::CreateDirectory(test_path)); // Doesn't work to create it on top of a non-dir test_path = test_path.Append(FILE_PATH_LITERAL("foobar.txt")); - EXPECT_FALSE(file_util::PathExists(test_path)); + EXPECT_FALSE(base::PathExists(test_path)); CreateTextFile(test_path, L"test file"); - EXPECT_TRUE(file_util::PathExists(test_path)); + EXPECT_TRUE(base::PathExists(test_path)); EXPECT_FALSE(file_util::CreateDirectory(test_path)); EXPECT_TRUE(base::Delete(test_root, true)); - EXPECT_FALSE(file_util::PathExists(test_root)); - EXPECT_FALSE(file_util::PathExists(test_path)); + EXPECT_FALSE(base::PathExists(test_root)); + EXPECT_FALSE(base::PathExists(test_path)); // Verify assumptions made by the Windows implementation: // 1. The current directory always exists. @@ -1794,7 +1794,7 @@ TEST_F(FileUtilTest, CreateDirectoryTest) { FilePath invalid_drive(FILE_PATH_LITERAL("o:\\")); FilePath invalid_path = invalid_drive.Append(FILE_PATH_LITERAL("some\\inaccessible\\dir")); - if (!file_util::PathExists(invalid_drive)) { + if (!base::PathExists(invalid_drive)) { EXPECT_FALSE(file_util::CreateDirectory(invalid_path)); } #endif @@ -1804,16 +1804,16 @@ TEST_F(FileUtilTest, DetectDirectoryTest) { // Check a directory FilePath test_root = temp_dir_.path().Append(FILE_PATH_LITERAL("detect_directory_test")); - EXPECT_FALSE(file_util::PathExists(test_root)); + EXPECT_FALSE(base::PathExists(test_root)); EXPECT_TRUE(file_util::CreateDirectory(test_root)); - EXPECT_TRUE(file_util::PathExists(test_root)); + EXPECT_TRUE(base::PathExists(test_root)); EXPECT_TRUE(file_util::DirectoryExists(test_root)); // Check a file FilePath test_path = test_root.Append(FILE_PATH_LITERAL("foobar.txt")); - EXPECT_FALSE(file_util::PathExists(test_path)); + EXPECT_FALSE(base::PathExists(test_path)); CreateTextFile(test_path, L"test file"); - EXPECT_TRUE(file_util::PathExists(test_path)); + EXPECT_TRUE(base::PathExists(test_path)); EXPECT_FALSE(file_util::DirectoryExists(test_path)); EXPECT_TRUE(base::Delete(test_path, false)); @@ -1934,13 +1934,13 @@ TEST_F(FileUtilTest, AppendToFile) { temp_dir_.path().Append(FILE_PATH_LITERAL("FilePathTest")); // Create a fresh, empty copy of this directory. - if (file_util::PathExists(data_dir)) { + if (base::PathExists(data_dir)) { 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)) { + if (base::PathExists(data_dir)) { ASSERT_TRUE(base::Delete(data_dir, true)); } ASSERT_TRUE(file_util::CreateDirectory(data_dir)); @@ -1962,7 +1962,7 @@ TEST_F(FileUtilTest, TouchFile) { temp_dir_.path().Append(FILE_PATH_LITERAL("FilePathTest")); // Create a fresh, empty copy of this directory. - if (file_util::PathExists(data_dir)) { + if (base::PathExists(data_dir)) { ASSERT_TRUE(base::Delete(data_dir, true)); } ASSERT_TRUE(file_util::CreateDirectory(data_dir)); @@ -1995,7 +1995,7 @@ TEST_F(FileUtilTest, TouchFile) { TEST_F(FileUtilTest, IsDirectoryEmpty) { FilePath empty_dir = temp_dir_.path().Append(FILE_PATH_LITERAL("EmptyDir")); - ASSERT_FALSE(file_util::PathExists(empty_dir)); + ASSERT_FALSE(base::PathExists(empty_dir)); ASSERT_TRUE(file_util::CreateDirectory(empty_dir)); @@ -2123,7 +2123,7 @@ TEST_F(VerifyPathControlledByUserTest, Symlinks) { << "Failed to create symlink."; FilePath file_path_with_link = link_to_sub_dir.AppendASCII("file.txt"); - ASSERT_TRUE(file_util::PathExists(file_path_with_link)); + ASSERT_TRUE(base::PathExists(file_path_with_link)); EXPECT_FALSE( file_util::VerifyPathControlledByUser( diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 928b66e..90d8fca 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -180,7 +180,7 @@ bool CopyDirectory(const FilePath& from_path, const FilePath& to_path, // Instead of creating a new directory, we copy the old one to include the // security information of the folder as part of the copy. - if (!file_util::PathExists(to_path)) { + if (!PathExists(to_path)) { // Except that Vista fails to do that, and instead do a recursive copy if // the target directory doesn't exist. if (base::win::GetVersion() >= base::win::VERSION_VISTA) @@ -193,6 +193,11 @@ bool CopyDirectory(const FilePath& from_path, const FilePath& to_path, return ShellCopy(directory, to_path, false); } +bool PathExists(const FilePath& path) { + ThreadRestrictions::AssertIOAllowed(); + return (GetFileAttributes(path.value().c_str()) != INVALID_FILE_ATTRIBUTES); +} + } // namespace base // ----------------------------------------------------------------------------- @@ -202,11 +207,6 @@ namespace file_util { using base::FilePath; using base::kFileShareAll; -bool PathExists(const FilePath& path) { - base::ThreadRestrictions::AssertIOAllowed(); - return (GetFileAttributes(path.value().c_str()) != INVALID_FILE_ATTRIBUTES); -} - bool PathIsWritable(const FilePath& path) { base::ThreadRestrictions::AssertIOAllowed(); HANDLE dir = diff --git a/base/files/file_path_watcher_linux.cc b/base/files/file_path_watcher_linux.cc index 8cf95ed..b9270ee 100644 --- a/base/files/file_path_watcher_linux.cc +++ b/base/files/file_path_watcher_linux.cc @@ -351,7 +351,7 @@ void FilePathWatcherImpl::OnFilePathChanged(InotifyReader::Watch fired_watch, // recheck. if (target_changed || (change_on_target_path && !created) || - (change_on_target_path && file_util::PathExists(target_))) { + (change_on_target_path && PathExists(target_))) { callback_.Run(target_, false); return; } diff --git a/base/files/file_util_proxy.cc b/base/files/file_util_proxy.cc index 9f65da8e..5eb9fe5 100644 --- a/base/files/file_util_proxy.cc +++ b/base/files/file_util_proxy.cc @@ -107,7 +107,7 @@ class GetFileInfoHelper { : error_(PLATFORM_FILE_OK) {} void RunWorkForFilePath(const FilePath& file_path) { - if (!file_util::PathExists(file_path)) { + if (!PathExists(file_path)) { error_ = PLATFORM_FILE_ERROR_NOT_FOUND; return; } @@ -210,7 +210,7 @@ PlatformFileError CloseAdapter(PlatformFile file_handle) { } PlatformFileError DeleteAdapter(const FilePath& file_path, bool recursive) { - if (!file_util::PathExists(file_path)) { + if (!PathExists(file_path)) { return PLATFORM_FILE_ERROR_NOT_FOUND; } if (!base::Delete(file_path, recursive)) { diff --git a/base/files/file_util_proxy_unittest.cc b/base/files/file_util_proxy_unittest.cc index f524ba4..e8680bb 100644 --- a/base/files/file_util_proxy_unittest.cc +++ b/base/files/file_util_proxy_unittest.cc @@ -128,13 +128,13 @@ TEST_F(FileUtilProxyTest, CreateOrOpen_Create) { EXPECT_EQ(PLATFORM_FILE_OK, error_); EXPECT_TRUE(created_); EXPECT_NE(kInvalidPlatformFileValue, file_); - EXPECT_TRUE(file_util::PathExists(test_path())); + EXPECT_TRUE(PathExists(test_path())); } TEST_F(FileUtilProxyTest, CreateOrOpen_Open) { // Creates a file. file_util::WriteFile(test_path(), NULL, 0); - ASSERT_TRUE(file_util::PathExists(test_path())); + ASSERT_TRUE(PathExists(test_path())); // Opens the created file. FileUtilProxy::CreateOrOpen( @@ -159,7 +159,7 @@ TEST_F(FileUtilProxyTest, CreateOrOpen_OpenNonExistent) { EXPECT_EQ(PLATFORM_FILE_ERROR_NOT_FOUND, error_); EXPECT_FALSE(created_); EXPECT_EQ(kInvalidPlatformFileValue, file_); - EXPECT_FALSE(file_util::PathExists(test_path())); + EXPECT_FALSE(PathExists(test_path())); } TEST_F(FileUtilProxyTest, Close) { @@ -190,7 +190,7 @@ TEST_F(FileUtilProxyTest, CreateTemporary) { Bind(&FileUtilProxyTest::DidCreateTemporary, weak_factory_.GetWeakPtr())); MessageLoop::current()->Run(); EXPECT_EQ(PLATFORM_FILE_OK, error_); - EXPECT_TRUE(file_util::PathExists(path_)); + EXPECT_TRUE(PathExists(path_)); EXPECT_NE(kInvalidPlatformFileValue, file_); // The file should be writable. diff --git a/base/files/important_file_writer_unittest.cc b/base/files/important_file_writer_unittest.cc index 759436cf..3f24d10 100644 --- a/base/files/important_file_writer_unittest.cc +++ b/base/files/important_file_writer_unittest.cc @@ -61,11 +61,11 @@ class ImportantFileWriterTest : public testing::Test { TEST_F(ImportantFileWriterTest, Basic) { ImportantFileWriter writer(file_, MessageLoopProxy::current().get()); - EXPECT_FALSE(file_util::PathExists(writer.path())); + EXPECT_FALSE(PathExists(writer.path())); writer.WriteNow("foo"); RunLoop().RunUntilIdle(); - ASSERT_TRUE(file_util::PathExists(writer.path())); + ASSERT_TRUE(PathExists(writer.path())); EXPECT_EQ("foo", GetFileContent(writer.path())); } @@ -82,7 +82,7 @@ TEST_F(ImportantFileWriterTest, ScheduleWrite) { TimeDelta::FromMilliseconds(100)); MessageLoop::current()->Run(); EXPECT_FALSE(writer.HasPendingWrite()); - ASSERT_TRUE(file_util::PathExists(writer.path())); + ASSERT_TRUE(PathExists(writer.path())); EXPECT_EQ("foo", GetFileContent(writer.path())); } @@ -99,7 +99,7 @@ TEST_F(ImportantFileWriterTest, DoScheduledWrite) { TimeDelta::FromMilliseconds(100)); MessageLoop::current()->Run(); EXPECT_FALSE(writer.HasPendingWrite()); - ASSERT_TRUE(file_util::PathExists(writer.path())); + ASSERT_TRUE(PathExists(writer.path())); EXPECT_EQ("foo", GetFileContent(writer.path())); } @@ -115,7 +115,7 @@ TEST_F(ImportantFileWriterTest, BatchingWrites) { MessageLoop::QuitWhenIdleClosure(), TimeDelta::FromMilliseconds(100)); MessageLoop::current()->Run(); - ASSERT_TRUE(file_util::PathExists(writer.path())); + ASSERT_TRUE(PathExists(writer.path())); EXPECT_EQ("baz", GetFileContent(writer.path())); } diff --git a/base/json/json_file_value_serializer.cc b/base/json/json_file_value_serializer.cc index d6cff33..37371e8 100644 --- a/base/json/json_file_value_serializer.cc +++ b/base/json/json_file_value_serializer.cc @@ -55,7 +55,7 @@ int JSONFileValueSerializer::ReadFileToString(std::string* json_string) { return JSON_ACCESS_DENIED; } #endif - if (!file_util::PathExists(json_file_path_)) + if (!base::PathExists(json_file_path_)) return JSON_NO_SUCH_FILE; else return JSON_CANNOT_READ_FILE; diff --git a/base/json/json_reader_unittest.cc b/base/json/json_reader_unittest.cc index 0180f48..41650b4 100644 --- a/base/json/json_reader_unittest.cc +++ b/base/json/json_reader_unittest.cc @@ -544,7 +544,7 @@ TEST(JSONReaderTest, ReadFromFile) { FilePath path; ASSERT_TRUE(PathService::Get(base::DIR_TEST_DATA, &path)); path = path.AppendASCII("json"); - ASSERT_TRUE(file_util::PathExists(path)); + ASSERT_TRUE(base::PathExists(path)); std::string input; ASSERT_TRUE(file_util::ReadFileToString( diff --git a/base/json/json_value_serializer_unittest.cc b/base/json/json_value_serializer_unittest.cc index 78be11e..ce7129f 100644 --- a/base/json/json_value_serializer_unittest.cc +++ b/base/json/json_value_serializer_unittest.cc @@ -385,7 +385,7 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) { original_file_path = original_file_path.Append(FILE_PATH_LITERAL("serializer_test.json")); - ASSERT_TRUE(file_util::PathExists(original_file_path)); + ASSERT_TRUE(PathExists(original_file_path)); JSONFileValueSerializer deserializer(original_file_path); scoped_ptr<Value> root; @@ -417,10 +417,10 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) { const base::FilePath written_file_path = temp_dir_.path().Append(FILE_PATH_LITERAL("test_output.js")); - ASSERT_FALSE(file_util::PathExists(written_file_path)); + ASSERT_FALSE(PathExists(written_file_path)); JSONFileValueSerializer serializer(written_file_path); ASSERT_TRUE(serializer.Serialize(*root)); - ASSERT_TRUE(file_util::PathExists(written_file_path)); + ASSERT_TRUE(PathExists(written_file_path)); // Now compare file contents. EXPECT_TRUE(file_util::TextContentsEqual(original_file_path, @@ -434,7 +434,7 @@ TEST_F(JSONFileValueSerializerTest, RoundtripNested) { original_file_path = original_file_path.Append( FILE_PATH_LITERAL("serializer_nested_test.json")); - ASSERT_TRUE(file_util::PathExists(original_file_path)); + ASSERT_TRUE(PathExists(original_file_path)); JSONFileValueSerializer deserializer(original_file_path); scoped_ptr<Value> root; @@ -445,10 +445,10 @@ TEST_F(JSONFileValueSerializerTest, RoundtripNested) { base::FilePath written_file_path = temp_dir_.path().Append( FILE_PATH_LITERAL("test_output.json")); - ASSERT_FALSE(file_util::PathExists(written_file_path)); + ASSERT_FALSE(PathExists(written_file_path)); JSONFileValueSerializer serializer(written_file_path); ASSERT_TRUE(serializer.Serialize(*root)); - ASSERT_TRUE(file_util::PathExists(written_file_path)); + ASSERT_TRUE(PathExists(written_file_path)); // Now compare file contents. EXPECT_TRUE(file_util::TextContentsEqual(original_file_path, @@ -461,7 +461,7 @@ TEST_F(JSONFileValueSerializerTest, NoWhitespace) { ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &source_file_path)); source_file_path = source_file_path.Append( FILE_PATH_LITERAL("serializer_test_nowhitespace.json")); - ASSERT_TRUE(file_util::PathExists(source_file_path)); + ASSERT_TRUE(PathExists(source_file_path)); JSONFileValueSerializer serializer(source_file_path); scoped_ptr<Value> root; root.reset(serializer.Deserialize(NULL, NULL)); diff --git a/base/mac/mac_util_unittest.mm b/base/mac/mac_util_unittest.mm index 0e52cbc..d246757 100644 --- a/base/mac/mac_util_unittest.mm +++ b/base/mac/mac_util_unittest.mm @@ -246,7 +246,7 @@ TEST_F(MacUtilTest, TestRemoveQuarantineAttributeNonExistentPath) { ScopedTempDir temp_dir_; ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); FilePath non_existent_path = temp_dir_.path().Append("DummyPath"); - ASSERT_FALSE(file_util::PathExists(non_existent_path)); + ASSERT_FALSE(PathExists(non_existent_path)); EXPECT_FALSE(RemoveQuarantineAttribute(non_existent_path)); } diff --git a/base/memory/shared_memory_posix.cc b/base/memory/shared_memory_posix.cc index 2be787d..93e0b76 100644 --- a/base/memory/shared_memory_posix.cc +++ b/base/memory/shared_memory_posix.cc @@ -236,9 +236,8 @@ bool SharedMemory::Delete(const std::string& name) { if (!FilePathForMemoryName(name, &path)) return false; - if (file_util::PathExists(path)) { + if (PathExists(path)) return base::Delete(path, false); - } // Doesn't exist, so success. return true; diff --git a/base/nix/mime_util_xdg.cc b/base/nix/mime_util_xdg.cc index a611e4d..7c1d660 100644 --- a/base/nix/mime_util_xdg.cc +++ b/base/nix/mime_util_xdg.cc @@ -171,7 +171,7 @@ IconTheme::IconTheme(const std::string& name) if (!file_util::DirectoryExists(theme_path)) continue; FilePath theme_index = theme_path.Append("index.theme"); - if (!index_theme_loaded_ && file_util::PathExists(theme_index)) { + if (!index_theme_loaded_ && PathExists(theme_index)) { if (!LoadIndexTheme(theme_index)) return; index_theme_loaded_ = true; @@ -248,7 +248,7 @@ FilePath IconTheme::GetIconPathUnderSubdir(const std::string& icon_name, for (size_t i = 0; i < icon_formats->size(); ++i) { icon_path = dir_iter->Append(subdir); icon_path = icon_path.Append(icon_name + (*icon_formats)[i]); - if (file_util::PathExists(icon_path)) + if (PathExists(icon_path)) return icon_path; } } @@ -490,7 +490,7 @@ FilePath LookupFallbackIcon(const std::string& icon_name) { for (iter = icon_dirs->begin(); iter != icon_dirs->end(); ++iter) { for (size_t i = 0; i < icon_formats->size(); ++i) { FilePath icon = iter->first.Append(icon_name + (*icon_formats)[i]); - if (file_util::PathExists(icon)) + if (PathExists(icon)) return icon; } } @@ -640,7 +640,7 @@ FilePath GetMimeIcon(const std::string& mime_type, size_t size) { for (size_t i = 0; i < icon_names.size(); i++) { if (icon_names[i][0] == '/') { icon_file = FilePath(icon_names[i]); - if (file_util::PathExists(icon_file)) + if (PathExists(icon_file)) return icon_file; } else { icon_file = LookupIconInDefaultTheme(icon_names[i], size); diff --git a/base/path_service.cc b/base/path_service.cc index 5cfb1ef..89e58b2 100644 --- a/base/path_service.cc +++ b/base/path_service.cc @@ -253,7 +253,7 @@ bool PathService::OverrideAndCreateIfNeeded(int key, // Make sure the directory exists. We need to do this before we translate // this to the absolute path because on POSIX, MakeAbsoluteFilePath fails // if called on a non-existent path. - if (!file_util::PathExists(file_path) && + if (!base::PathExists(file_path) && !file_util::CreateDirectory(file_path)) return false; } diff --git a/base/path_service_unittest.cc b/base/path_service_unittest.cc index 68565cc..fbb2d76 100644 --- a/base/path_service_unittest.cc +++ b/base/path_service_unittest.cc @@ -73,7 +73,7 @@ bool ReturnsValidPath(int dir_type) { return false; #endif return result && !path.empty() && (!check_path_exists || - file_util::PathExists(path)); + base::PathExists(path)); } #if defined(OS_WIN) @@ -156,18 +156,18 @@ TEST_F(PathServiceTest, Override) { // PathService::Override should always create the path provided if it doesn't // exist. EXPECT_TRUE(PathService::Override(my_special_key, fake_cache_dir)); - EXPECT_TRUE(file_util::PathExists(fake_cache_dir)); + EXPECT_TRUE(base::PathExists(fake_cache_dir)); base::FilePath fake_cache_dir2(temp_dir.path().AppendASCII("cache2")); // PathService::OverrideAndCreateIfNeeded should obey the |create| parameter. PathService::OverrideAndCreateIfNeeded(my_special_key, fake_cache_dir2, false); - EXPECT_FALSE(file_util::PathExists(fake_cache_dir2)); + EXPECT_FALSE(base::PathExists(fake_cache_dir2)); EXPECT_TRUE(PathService::OverrideAndCreateIfNeeded(my_special_key, fake_cache_dir2, true)); - EXPECT_TRUE(file_util::PathExists(fake_cache_dir2)); + EXPECT_TRUE(base::PathExists(fake_cache_dir2)); } // Check if multiple overrides can co-exist. @@ -177,21 +177,21 @@ TEST_F(PathServiceTest, OverrideMultiple) { ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); base::FilePath fake_cache_dir1(temp_dir.path().AppendASCII("1")); EXPECT_TRUE(PathService::Override(my_special_key, fake_cache_dir1)); - EXPECT_TRUE(file_util::PathExists(fake_cache_dir1)); + EXPECT_TRUE(base::PathExists(fake_cache_dir1)); ASSERT_EQ(1, file_util::WriteFile(fake_cache_dir1.AppendASCII("t1"), ".", 1)); base::FilePath fake_cache_dir2(temp_dir.path().AppendASCII("2")); EXPECT_TRUE(PathService::Override(my_special_key + 1, fake_cache_dir2)); - EXPECT_TRUE(file_util::PathExists(fake_cache_dir2)); + EXPECT_TRUE(base::PathExists(fake_cache_dir2)); ASSERT_EQ(1, file_util::WriteFile(fake_cache_dir2.AppendASCII("t2"), ".", 1)); base::FilePath result; EXPECT_TRUE(PathService::Get(my_special_key, &result)); // Override might have changed the path representation but our test file // should be still there. - EXPECT_TRUE(file_util::PathExists(result.AppendASCII("t1"))); + EXPECT_TRUE(base::PathExists(result.AppendASCII("t1"))); EXPECT_TRUE(PathService::Get(my_special_key + 1, &result)); - EXPECT_TRUE(file_util::PathExists(result.AppendASCII("t2"))); + EXPECT_TRUE(base::PathExists(result.AppendASCII("t2"))); } TEST_F(PathServiceTest, RemoveOverride) { diff --git a/base/platform_file_unittest.cc b/base/platform_file_unittest.cc index 0ba7782..a1f3927 100644 --- a/base/platform_file_unittest.cc +++ b/base/platform_file_unittest.cc @@ -103,7 +103,7 @@ TEST(PlatformFile, CreatePlatformFile) { EXPECT_EQ(base::PLATFORM_FILE_OK, error_code); EXPECT_TRUE(base::ClosePlatformFile(file)); - EXPECT_FALSE(file_util::PathExists(file_path)); + EXPECT_FALSE(base::PathExists(file_path)); } TEST(PlatformFile, DeleteOpenFile) { @@ -139,7 +139,7 @@ TEST(PlatformFile, DeleteOpenFile) { // Close both handles and check that the file is gone. base::ClosePlatformFile(file); base::ClosePlatformFile(same_file); - EXPECT_FALSE(file_util::PathExists(file_path)); + EXPECT_FALSE(base::PathExists(file_path)); } TEST(PlatformFile, ReadWritePlatformFile) { diff --git a/base/prefs/json_pref_store.cc b/base/prefs/json_pref_store.cc index ff3c232..0b93f74 100644 --- a/base/prefs/json_pref_store.cc +++ b/base/prefs/json_pref_store.cc @@ -69,7 +69,7 @@ class FileThreadDeserializer JSONFileValueSerializer serializer(path); base::Value* value = serializer.Deserialize(&error_code, &error_msg); HandleErrors(value, path, error_code, error_msg, error); - *no_dir = !file_util::PathExists(path.DirName()); + *no_dir = !base::PathExists(path.DirName()); return value; } @@ -128,7 +128,7 @@ void FileThreadDeserializer::HandleErrors( // If they've ever had a parse error before, put them in another bucket. // TODO(erikkay) if we keep this error checking for very long, we may // want to differentiate between recent and long ago errors. - if (file_util::PathExists(bad)) + if (base::PathExists(bad)) *error = PersistentPrefStore::PREF_READ_ERROR_JSON_REPEAT; base::Move(path, bad); break; diff --git a/base/prefs/json_pref_store_unittest.cc b/base/prefs/json_pref_store_unittest.cc index c3b89a0..5c506d4 100644 --- a/base/prefs/json_pref_store_unittest.cc +++ b/base/prefs/json_pref_store_unittest.cc @@ -44,7 +44,7 @@ class JsonPrefStoreTest : public testing::Test { ASSERT_TRUE(PathService::Get(base::DIR_TEST_DATA, &data_dir_)); data_dir_ = data_dir_.AppendASCII("prefs"); - ASSERT_TRUE(file_util::PathExists(data_dir_)); + ASSERT_TRUE(PathExists(data_dir_)); } // The path to temporary directory used to contain the test operations. @@ -58,7 +58,7 @@ class JsonPrefStoreTest : public testing::Test { // Test fallback behavior for a nonexistent file. TEST_F(JsonPrefStoreTest, NonExistentFile) { base::FilePath bogus_input_file = data_dir_.AppendASCII("read.txt"); - ASSERT_FALSE(file_util::PathExists(bogus_input_file)); + ASSERT_FALSE(PathExists(bogus_input_file)); scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore( bogus_input_file, message_loop_.message_loop_proxy().get()); EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_NO_FILE, @@ -78,9 +78,9 @@ TEST_F(JsonPrefStoreTest, InvalidFile) { EXPECT_FALSE(pref_store->ReadOnly()); // The file should have been moved aside. - EXPECT_FALSE(file_util::PathExists(invalid_file)); + EXPECT_FALSE(PathExists(invalid_file)); base::FilePath moved_aside = temp_dir_.path().AppendASCII("invalid.bad"); - EXPECT_TRUE(file_util::PathExists(moved_aside)); + EXPECT_TRUE(PathExists(moved_aside)); EXPECT_TRUE(file_util::TextContentsEqual(invalid_file_original, moved_aside)); } @@ -144,7 +144,7 @@ void RunBasicJsonPrefStoreTest(JsonPrefStore* pref_store, EXPECT_EQ(214748364842LL, value); // Serialize and compare to expected output. - ASSERT_TRUE(file_util::PathExists(golden_output_file)); + ASSERT_TRUE(PathExists(golden_output_file)); pref_store->CommitPendingWrite(); RunLoop().RunUntilIdle(); EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, output_file)); @@ -157,7 +157,7 @@ TEST_F(JsonPrefStoreTest, Basic) { // Test that the persistent value can be loaded. base::FilePath input_file = temp_dir_.path().AppendASCII("write.json"); - ASSERT_TRUE(file_util::PathExists(input_file)); + ASSERT_TRUE(PathExists(input_file)); scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(input_file, message_loop_.message_loop_proxy().get()); ASSERT_EQ(PersistentPrefStore::PREF_READ_ERROR_NONE, pref_store->ReadPrefs()); @@ -183,7 +183,7 @@ TEST_F(JsonPrefStoreTest, BasicAsync) { // Test that the persistent value can be loaded. base::FilePath input_file = temp_dir_.path().AppendASCII("write.json"); - ASSERT_TRUE(file_util::PathExists(input_file)); + ASSERT_TRUE(PathExists(input_file)); scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(input_file, message_loop_.message_loop_proxy().get()); @@ -220,7 +220,7 @@ TEST_F(JsonPrefStoreTest, BasicAsync) { // Tests asynchronous reading of the file when there is no file. TEST_F(JsonPrefStoreTest, AsyncNonExistingFile) { base::FilePath bogus_input_file = data_dir_.AppendASCII("read.txt"); - ASSERT_FALSE(file_util::PathExists(bogus_input_file)); + ASSERT_FALSE(PathExists(bogus_input_file)); scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore( bogus_input_file, message_loop_.message_loop_proxy().get()); MockPrefStoreObserver mock_observer; @@ -246,7 +246,7 @@ TEST_F(JsonPrefStoreTest, NeedsEmptyValue) { pref_file)); // Test that the persistent value can be loaded. - ASSERT_TRUE(file_util::PathExists(pref_file)); + ASSERT_TRUE(PathExists(pref_file)); scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(pref_file, message_loop_.message_loop_proxy().get()); ASSERT_EQ(PersistentPrefStore::PREF_READ_ERROR_NONE, pref_store->ReadPrefs()); @@ -281,7 +281,7 @@ TEST_F(JsonPrefStoreTest, NeedsEmptyValue) { // Compare to expected output. base::FilePath golden_output_file = data_dir_.AppendASCII("write.golden.need_empty_value.json"); - ASSERT_TRUE(file_util::PathExists(golden_output_file)); + ASSERT_TRUE(PathExists(golden_output_file)); EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, pref_file)); } diff --git a/base/process/memory_linux.cc b/base/process/memory_linux.cc index 81cf20c..53afa1a 100644 --- a/base/process/memory_linux.cc +++ b/base/process/memory_linux.cc @@ -150,7 +150,7 @@ bool AdjustOOMScore(ProcessId process, int score) { // Attempt to write the newer oom_score_adj file first. FilePath oom_file = oom_path.AppendASCII("oom_score_adj"); - if (file_util::PathExists(oom_file)) { + if (PathExists(oom_file)) { std::string score_str = IntToString(score); DVLOG(1) << "Adjusting oom_score_adj of " << process << " to " << score_str; @@ -163,7 +163,7 @@ bool AdjustOOMScore(ProcessId process, int score) { // If the oom_score_adj file doesn't exist, then we write the old // style file and translate the oom_adj score to the range 0-15. oom_file = oom_path.AppendASCII("oom_adj"); - if (file_util::PathExists(oom_file)) { + if (PathExists(oom_file)) { // Max score for the old oom_adj range. Used for conversion of new // values to old values. const int kMaxOldOomScore = 15; diff --git a/base/test/test_file_util_win.cc b/base/test/test_file_util_win.cc index 9e3697b..3cfd233 100644 --- a/base/test/test_file_util_win.cc +++ b/base/test/test_file_util_win.cc @@ -119,7 +119,7 @@ bool DieFileDie(const base::FilePath& file, bool recurse) { const base::TimeDelta kTimeout = base::TimeDelta::FromSeconds(10) / kIterations; - if (!file_util::PathExists(file)) + if (!base::PathExists(file)) return true; // Sometimes Delete fails, so try a few more times. Divide the timeout diff --git a/base/win/shortcut.cc b/base/win/shortcut.cc index eb7a72c..57a93dc 100644 --- a/base/win/shortcut.cc +++ b/base/win/shortcut.cc @@ -53,7 +53,7 @@ bool CreateOrUpdateShortcutLink(const FilePath& shortcut_path, return false; } - bool shortcut_existed = file_util::PathExists(shortcut_path); + bool shortcut_existed = PathExists(shortcut_path); // Interfaces to the old shortcut when replacing an existing shortcut. ScopedComPtr<IShellLink> old_i_shell_link; diff --git a/base/win/shortcut_unittest.cc b/base/win/shortcut_unittest.cc index 56f3b4a..b3247b6 100644 --- a/base/win/shortcut_unittest.cc +++ b/base/win/shortcut_unittest.cc @@ -212,7 +212,7 @@ TEST_F(ShortcutTest, UpdateShortcutClearArguments) { TEST_F(ShortcutTest, FailUpdateShortcutThatDoesNotExist) { ASSERT_FALSE(CreateOrUpdateShortcutLink( link_file_, link_properties_, SHORTCUT_UPDATE_EXISTING)); - ASSERT_FALSE(file_util::PathExists(link_file_)); + ASSERT_FALSE(PathExists(link_file_)); } TEST_F(ShortcutTest, ReplaceShortcutAllProperties) { @@ -249,7 +249,7 @@ TEST_F(ShortcutTest, ReplaceShortcutSomeProperties) { TEST_F(ShortcutTest, FailReplaceShortcutThatDoesNotExist) { ASSERT_FALSE(CreateOrUpdateShortcutLink( link_file_, link_properties_, SHORTCUT_REPLACE_EXISTING)); - ASSERT_FALSE(file_util::PathExists(link_file_)); + ASSERT_FALSE(PathExists(link_file_)); } // Test that the old arguments remain on the replaced shortcut when not |