Move directory creation functions to base namespace.
BUG=
Review URL: https://codereview.chromium.org/100573002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238446 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: 426d1c945bcb1a8479d92a7dd023c34cbbc7a261
diff --git a/base/file_util.cc b/base/file_util.cc
index f6d8657..1639cce 100644
--- a/base/file_util.cc
+++ b/base/file_util.cc
@@ -161,6 +161,10 @@
return CreateAndOpenTemporaryFileInDir(directory, path);
}
+bool CreateDirectory(const FilePath& full_path) {
+ return CreateDirectoryAndGetError(full_path, NULL);
+}
+
} // namespace base
// -----------------------------------------------------------------------------
@@ -171,10 +175,6 @@
using base::FilePath;
using base::kMaxUniqueFiles;
-bool CreateDirectory(const base::FilePath& full_path) {
- return CreateDirectoryAndGetError(full_path, NULL);
-}
-
bool GetFileSize(const FilePath& file_path, int64* file_size) {
base::PlatformFileInfo info;
if (!GetFileInfo(file_path, &info))
diff --git a/base/file_util.h b/base/file_util.h
index 3437890..30d9d09 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -250,22 +250,22 @@
const FilePath::StringType& prefix,
FilePath* new_dir);
-} // namespace base
-
-// -----------------------------------------------------------------------------
-
-namespace file_util {
-
// Creates a directory, as well as creating any parent directories, if they
// don't exist. Returns 'true' on successful creation, or if the directory
// already exists. The directory is only readable by the current user.
// Returns true on success, leaving *error unchanged.
// Returns false on failure and sets *error appropriately, if it is non-NULL.
-BASE_EXPORT bool CreateDirectoryAndGetError(const base::FilePath& full_path,
- base::PlatformFileError* error);
+BASE_EXPORT bool CreateDirectoryAndGetError(const FilePath& full_path,
+ PlatformFileError* error);
// Backward-compatible convenience method for the above.
-BASE_EXPORT bool CreateDirectory(const base::FilePath& full_path);
+BASE_EXPORT bool CreateDirectory(const FilePath& full_path);
+
+} // namespace base
+
+// -----------------------------------------------------------------------------
+
+namespace file_util {
// Returns the file size. Returns true on success.
BASE_EXPORT bool GetFileSize(const base::FilePath& file_path, int64* file_size);
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index bfdc926..f566efb 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -588,27 +588,9 @@
return CreateTemporaryDirInDirImpl(tmpdir, TempFileName(), new_temp_path);
}
-
-} // namespace base
-
-// -----------------------------------------------------------------------------
-
-namespace file_util {
-
-using base::stat_wrapper_t;
-using base::CallStat;
-using base::CallLstat;
-using base::CreateAndOpenFdForTemporaryFile;
-using base::DirectoryExists;
-using base::FileEnumerator;
-using base::FilePath;
-using base::MakeAbsoluteFilePath;
-using base::RealPath;
-using base::VerifySpecificPathControlledByUser;
-
bool CreateDirectoryAndGetError(const FilePath& full_path,
- base::PlatformFileError* error) {
- base::ThreadRestrictions::AssertIOAllowed(); // For call to mkdir().
+ PlatformFileError* error) {
+ ThreadRestrictions::AssertIOAllowed(); // For call to mkdir().
std::vector<FilePath> subpaths;
// Collect a list of all parent directories.
@@ -634,13 +616,30 @@
int saved_errno = errno;
if (!DirectoryExists(*i)) {
if (error)
- *error = base::ErrnoToPlatformFileError(saved_errno);
+ *error = ErrnoToPlatformFileError(saved_errno);
return false;
}
}
return true;
}
+} // namespace base
+
+// -----------------------------------------------------------------------------
+
+namespace file_util {
+
+using base::stat_wrapper_t;
+using base::CallStat;
+using base::CallLstat;
+using base::CreateAndOpenFdForTemporaryFile;
+using base::DirectoryExists;
+using base::FileEnumerator;
+using base::FilePath;
+using base::MakeAbsoluteFilePath;
+using base::RealPath;
+using base::VerifySpecificPathControlledByUser;
+
base::FilePath MakeUniqueDirectory(const base::FilePath& path) {
const int kMaxAttempts = 20;
for (int attempts = 0; attempts < kMaxAttempts; attempts++) {
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 2dac484..9289438 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -254,7 +254,7 @@
EXPECT_EQ(20ll, size_f1);
FilePath subdir_path = temp_dir_.path().Append(FPL("Level2"));
- file_util::CreateDirectory(subdir_path);
+ base::CreateDirectory(subdir_path);
FilePath file_02 = subdir_path.Append(FPL("The file 02.txt"));
CreateTextFile(file_02, L"123456789012345678901234567890");
@@ -263,7 +263,7 @@
EXPECT_EQ(30ll, size_f2);
FilePath subsubdir_path = subdir_path.Append(FPL("Level3"));
- file_util::CreateDirectory(subsubdir_path);
+ base::CreateDirectory(subsubdir_path);
FilePath file_03 = subsubdir_path.Append(FPL("The file 03.txt"));
CreateTextFile(file_03, L"123");
@@ -278,7 +278,7 @@
FilePath file_a_path = temp_dir_.path().Append(FPL("file_a"));
FilePath dir_path = temp_dir_.path().Append(FPL("dir"));
FilePath file_b_path = dir_path.Append(FPL("file_b"));
- file_util::CreateDirectory(dir_path);
+ base::CreateDirectory(dir_path);
FilePath normalized_file_a_path, normalized_file_b_path;
ASSERT_FALSE(PathExists(file_a_path));
@@ -321,10 +321,10 @@
// |-> to_sub_long (reparse point to temp_dir\sub_a\long_name_\sub_long)
FilePath base_a = temp_dir_.path().Append(FPL("base_a"));
- ASSERT_TRUE(file_util::CreateDirectory(base_a));
+ ASSERT_TRUE(base::CreateDirectory(base_a));
FilePath sub_a = base_a.Append(FPL("sub_a"));
- ASSERT_TRUE(file_util::CreateDirectory(sub_a));
+ ASSERT_TRUE(base::CreateDirectory(sub_a));
FilePath file_txt = sub_a.Append(FPL("file.txt"));
CreateTextFile(file_txt, bogus_content);
@@ -352,26 +352,26 @@
ASSERT_EQ(MAX_PATH - kCreateDirLimit, deep_file.value().length());
FilePath sub_long = deep_file.DirName();
- ASSERT_TRUE(file_util::CreateDirectory(sub_long));
+ ASSERT_TRUE(base::CreateDirectory(sub_long));
CreateTextFile(deep_file, bogus_content);
FilePath base_b = temp_dir_.path().Append(FPL("base_b"));
- ASSERT_TRUE(file_util::CreateDirectory(base_b));
+ ASSERT_TRUE(base::CreateDirectory(base_b));
FilePath to_sub_a = base_b.Append(FPL("to_sub_a"));
- ASSERT_TRUE(file_util::CreateDirectory(to_sub_a));
+ ASSERT_TRUE(base::CreateDirectory(to_sub_a));
FilePath normalized_path;
{
ReparsePoint reparse_to_sub_a(to_sub_a, sub_a);
ASSERT_TRUE(reparse_to_sub_a.IsValid());
FilePath to_base_b = base_b.Append(FPL("to_base_b"));
- ASSERT_TRUE(file_util::CreateDirectory(to_base_b));
+ ASSERT_TRUE(base::CreateDirectory(to_base_b));
ReparsePoint reparse_to_base_b(to_base_b, base_b);
ASSERT_TRUE(reparse_to_base_b.IsValid());
FilePath to_sub_long = base_b.Append(FPL("to_sub_long"));
- ASSERT_TRUE(file_util::CreateDirectory(to_sub_long));
+ ASSERT_TRUE(base::CreateDirectory(to_sub_long));
ReparsePoint reparse_to_sub_long(to_sub_long, sub_long);
ASSERT_TRUE(reparse_to_sub_long.IsValid());
@@ -492,7 +492,7 @@
TEST_F(FileUtilTest, GetPlatformFileInfoForDirectory) {
FilePath empty_dir = temp_dir_.path().Append(FPL("gpfi_test"));
- ASSERT_TRUE(file_util::CreateDirectory(empty_dir));
+ ASSERT_TRUE(base::CreateDirectory(empty_dir));
win::ScopedHandle dir(
::CreateFile(empty_dir.value().c_str(),
FILE_ALL_ACCESS,
@@ -518,7 +518,7 @@
const FilePath::CharType kLongDirName[] = FPL("A long path");
const FilePath::CharType kTestSubDirName[] = FPL("test");
FilePath long_test_dir = temp_dir_.path().Append(kLongDirName);
- ASSERT_TRUE(file_util::CreateDirectory(long_test_dir));
+ ASSERT_TRUE(base::CreateDirectory(long_test_dir));
// kLongDirName is not a 8.3 component. So GetShortName() should give us a
// different short name.
@@ -543,7 +543,7 @@
// directories. (Note that this assumption is true for NTFS, but not for some
// network file systems. E.g. AFS).
FilePath access_test_dir = long_test_dir.Append(kTestSubDirName);
- ASSERT_TRUE(file_util::CreateDirectory(access_test_dir));
+ ASSERT_TRUE(base::CreateDirectory(access_test_dir));
file_util::PermissionRestorer long_test_dir_restorer(long_test_dir);
ASSERT_TRUE(file_util::MakeFileUnreadable(long_test_dir));
@@ -583,7 +583,7 @@
// Link to a directory.
link_from = temp_dir_.path().Append(FPL("from_dir"));
link_to = temp_dir_.path().Append(FPL("to_dir"));
- ASSERT_TRUE(file_util::CreateDirectory(link_to));
+ ASSERT_TRUE(base::CreateDirectory(link_to));
ASSERT_TRUE(CreateSymbolicLink(link_to, link_from))
<< "Failed to create directory symlink.";
@@ -618,7 +618,7 @@
// Link to a directory.
link_from = temp_dir_.path().Append(FPL("from_dir"));
link_to = temp_dir_.path().Append(FPL("to_dir"));
- ASSERT_TRUE(file_util::CreateDirectory(link_to));
+ ASSERT_TRUE(base::CreateDirectory(link_to));
ASSERT_TRUE(CreateSymbolicLink(link_to, link_from))
<< "Failed to create directory symlink.";
@@ -797,7 +797,7 @@
// Create a directory path.
FilePath subdir_path =
temp_dir_.path().Append(FPL("PermissionTest1"));
- file_util::CreateDirectory(subdir_path);
+ base::CreateDirectory(subdir_path);
ASSERT_TRUE(PathExists(subdir_path));
// Create a dummy file to enumerate.
@@ -854,7 +854,7 @@
ASSERT_TRUE(PathExists(file_name));
FilePath subdir_path = temp_dir_.path().Append(FPL("DeleteWildCardDir"));
- file_util::CreateDirectory(subdir_path);
+ base::CreateDirectory(subdir_path);
ASSERT_TRUE(PathExists(subdir_path));
// Create the wildcard path
@@ -877,7 +877,7 @@
// Create a file and a directory
FilePath subdir_path =
temp_dir_.path().Append(FPL("DeleteNonExistantWildCard"));
- file_util::CreateDirectory(subdir_path);
+ base::CreateDirectory(subdir_path);
ASSERT_TRUE(PathExists(subdir_path));
// Create the wildcard path
@@ -898,7 +898,7 @@
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);
+ base::CreateDirectory(test_subdir);
ASSERT_TRUE(PathExists(test_subdir));
FilePath file_name = test_subdir.Append(FPL("Test DeleteDir.txt"));
@@ -906,11 +906,11 @@
ASSERT_TRUE(PathExists(file_name));
FilePath subdir_path1 = test_subdir.Append(FPL("TestSubDir1"));
- file_util::CreateDirectory(subdir_path1);
+ base::CreateDirectory(subdir_path1);
ASSERT_TRUE(PathExists(subdir_path1));
FilePath subdir_path2 = test_subdir.Append(FPL("TestSubDir2"));
- file_util::CreateDirectory(subdir_path2);
+ base::CreateDirectory(subdir_path2);
ASSERT_TRUE(PathExists(subdir_path2));
// Delete non-recursively and check that the empty dir got deleted
@@ -928,7 +928,7 @@
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);
+ base::CreateDirectory(test_subdir);
ASSERT_TRUE(PathExists(test_subdir));
FilePath file_name = test_subdir.Append(FPL("Test DeleteDirRecursive.txt"));
@@ -936,11 +936,11 @@
ASSERT_TRUE(PathExists(file_name));
FilePath subdir_path1 = test_subdir.Append(FPL("TestSubDir1"));
- file_util::CreateDirectory(subdir_path1);
+ base::CreateDirectory(subdir_path1);
ASSERT_TRUE(PathExists(subdir_path1));
FilePath subdir_path2 = test_subdir.Append(FPL("TestSubDir2"));
- file_util::CreateDirectory(subdir_path2);
+ base::CreateDirectory(subdir_path2);
ASSERT_TRUE(PathExists(subdir_path2));
// Delete recursively and check that the empty dir got deleted
@@ -1004,7 +1004,7 @@
// The destination directory
FilePath dir_name_to =
temp_dir_.path().Append(FILE_PATH_LITERAL("Destination"));
- file_util::CreateDirectory(dir_name_to);
+ base::CreateDirectory(dir_name_to);
ASSERT_TRUE(PathExists(dir_name_to));
EXPECT_FALSE(Move(file_name_from, dir_name_to));
@@ -1015,7 +1015,7 @@
// Create a directory
FilePath dir_name_from =
temp_dir_.path().Append(FILE_PATH_LITERAL("Move_From_Subdir"));
- file_util::CreateDirectory(dir_name_from);
+ base::CreateDirectory(dir_name_from);
ASSERT_TRUE(PathExists(dir_name_from));
// Create a file under the directory
@@ -1056,7 +1056,7 @@
// Create a directory
FilePath dir_name_from =
temp_dir_.path().Append(FILE_PATH_LITERAL("Move_From_Subdir"));
- file_util::CreateDirectory(dir_name_from);
+ base::CreateDirectory(dir_name_from);
ASSERT_TRUE(PathExists(dir_name_from));
// Create a file under the directory
@@ -1075,7 +1075,7 @@
dir_name_to.Append(FILE_PATH_LITERAL("Move_Test_File.txt"));
// Create the destination directory.
- file_util::CreateDirectory(dir_name_exists);
+ base::CreateDirectory(dir_name_exists);
ASSERT_TRUE(PathExists(dir_name_exists));
EXPECT_TRUE(Move(dir_name_from, dir_name_to));
@@ -1091,7 +1091,7 @@
// Create a directory.
FilePath dir_name_from =
temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir"));
- file_util::CreateDirectory(dir_name_from);
+ base::CreateDirectory(dir_name_from);
ASSERT_TRUE(PathExists(dir_name_from));
// Create a file under the directory.
@@ -1103,7 +1103,7 @@
// Create a subdirectory.
FilePath subdir_name_from =
dir_name_from.Append(FILE_PATH_LITERAL("Subdir"));
- file_util::CreateDirectory(subdir_name_from);
+ base::CreateDirectory(subdir_name_from);
ASSERT_TRUE(PathExists(subdir_name_from));
// Create a file under the subdirectory.
@@ -1141,7 +1141,7 @@
// Create a directory.
FilePath dir_name_from =
temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir"));
- file_util::CreateDirectory(dir_name_from);
+ base::CreateDirectory(dir_name_from);
ASSERT_TRUE(PathExists(dir_name_from));
// Create a file under the directory.
@@ -1153,7 +1153,7 @@
// Create a subdirectory.
FilePath subdir_name_from =
dir_name_from.Append(FILE_PATH_LITERAL("Subdir"));
- file_util::CreateDirectory(subdir_name_from);
+ base::CreateDirectory(subdir_name_from);
ASSERT_TRUE(PathExists(subdir_name_from));
// Create a file under the subdirectory.
@@ -1176,7 +1176,7 @@
subdir_name_to.Append(FILE_PATH_LITERAL("Copy_Test_File.txt"));
// Create the destination directory.
- file_util::CreateDirectory(dir_name_exists);
+ base::CreateDirectory(dir_name_exists);
ASSERT_TRUE(PathExists(dir_name_exists));
EXPECT_TRUE(CopyDirectory(dir_name_from, dir_name_exists, true));
@@ -1196,7 +1196,7 @@
// Create a directory.
FilePath dir_name_from =
temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir"));
- file_util::CreateDirectory(dir_name_from);
+ base::CreateDirectory(dir_name_from);
ASSERT_TRUE(PathExists(dir_name_from));
// Create a file under the directory.
@@ -1208,7 +1208,7 @@
// Create a subdirectory.
FilePath subdir_name_from =
dir_name_from.Append(FILE_PATH_LITERAL("Subdir"));
- file_util::CreateDirectory(subdir_name_from);
+ base::CreateDirectory(subdir_name_from);
ASSERT_TRUE(PathExists(subdir_name_from));
// Create a file under the subdirectory.
@@ -1243,7 +1243,7 @@
// Create a directory.
FilePath dir_name_from =
temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir"));
- file_util::CreateDirectory(dir_name_from);
+ base::CreateDirectory(dir_name_from);
ASSERT_TRUE(PathExists(dir_name_from));
// Create a file under the directory.
@@ -1255,7 +1255,7 @@
// Create a subdirectory.
FilePath subdir_name_from =
dir_name_from.Append(FILE_PATH_LITERAL("Subdir"));
- file_util::CreateDirectory(subdir_name_from);
+ base::CreateDirectory(subdir_name_from);
ASSERT_TRUE(PathExists(subdir_name_from));
// Create a file under the subdirectory.
@@ -1273,7 +1273,7 @@
dir_name_to.Append(FILE_PATH_LITERAL("Subdir"));
// Create the destination directory.
- file_util::CreateDirectory(dir_name_to);
+ base::CreateDirectory(dir_name_to);
ASSERT_TRUE(PathExists(dir_name_to));
EXPECT_TRUE(CopyDirectory(dir_name_from, dir_name_to, false));
@@ -1336,7 +1336,7 @@
// The destination
FilePath dir_name_to =
temp_dir_.path().Append(FILE_PATH_LITERAL("Destination"));
- file_util::CreateDirectory(dir_name_to);
+ base::CreateDirectory(dir_name_to);
ASSERT_TRUE(PathExists(dir_name_to));
FilePath file_name_to =
dir_name_to.Append(FILE_PATH_LITERAL("Copy_Test_File.txt"));
@@ -1351,7 +1351,7 @@
// Create a directory.
FilePath dir_name_from =
temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir"));
- file_util::CreateDirectory(dir_name_from);
+ base::CreateDirectory(dir_name_from);
ASSERT_TRUE(PathExists(dir_name_from));
// Create a file under the directory.
@@ -1388,7 +1388,7 @@
// Create a directory
FilePath dir_name_from =
temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir"));
- file_util::CreateDirectory(dir_name_from);
+ base::CreateDirectory(dir_name_from);
ASSERT_TRUE(PathExists(dir_name_from));
// Create a file under the directory
@@ -1523,7 +1523,7 @@
// Create a directory
FilePath dir_name_from =
temp_dir_.path().Append(FILE_PATH_LITERAL("CopyAndDelete_From_Subdir"));
- file_util::CreateDirectory(dir_name_from);
+ base::CreateDirectory(dir_name_from);
ASSERT_TRUE(PathExists(dir_name_from));
// Create a file under the directory
@@ -1652,17 +1652,17 @@
#endif
EXPECT_FALSE(PathExists(test_path));
- EXPECT_TRUE(file_util::CreateDirectory(test_path));
+ EXPECT_TRUE(base::CreateDirectory(test_path));
EXPECT_TRUE(PathExists(test_path));
// CreateDirectory returns true if the DirectoryExists returns true.
- EXPECT_TRUE(file_util::CreateDirectory(test_path));
+ EXPECT_TRUE(base::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(PathExists(test_path));
CreateTextFile(test_path, L"test file");
EXPECT_TRUE(PathExists(test_path));
- EXPECT_FALSE(file_util::CreateDirectory(test_path));
+ EXPECT_FALSE(base::CreateDirectory(test_path));
EXPECT_TRUE(DeleteFile(test_root, true));
EXPECT_FALSE(PathExists(test_root));
@@ -1680,16 +1680,16 @@
// Given these assumptions hold, it should be safe to
// test that "creating" these directories succeeds.
- EXPECT_TRUE(file_util::CreateDirectory(
+ EXPECT_TRUE(base::CreateDirectory(
FilePath(FilePath::kCurrentDirectory)));
- EXPECT_TRUE(file_util::CreateDirectory(top_level));
+ EXPECT_TRUE(base::CreateDirectory(top_level));
#if defined(OS_WIN)
FilePath invalid_drive(FILE_PATH_LITERAL("o:\\"));
FilePath invalid_path =
invalid_drive.Append(FILE_PATH_LITERAL("some\\inaccessible\\dir"));
if (!PathExists(invalid_drive)) {
- EXPECT_FALSE(file_util::CreateDirectory(invalid_path));
+ EXPECT_FALSE(base::CreateDirectory(invalid_path));
}
#endif
}
@@ -1699,7 +1699,7 @@
FilePath test_root =
temp_dir_.path().Append(FILE_PATH_LITERAL("detect_directory_test"));
EXPECT_FALSE(PathExists(test_root));
- EXPECT_TRUE(file_util::CreateDirectory(test_root));
+ EXPECT_TRUE(base::CreateDirectory(test_root));
EXPECT_TRUE(PathExists(test_root));
EXPECT_TRUE(DirectoryExists(test_root));
// Check a file
@@ -1729,11 +1729,11 @@
// create the directories
FilePath dir1 = temp_dir_.path().Append(FPL("dir1"));
- EXPECT_TRUE(file_util::CreateDirectory(dir1));
+ EXPECT_TRUE(base::CreateDirectory(dir1));
FilePath dir2 = temp_dir_.path().Append(FPL("dir2"));
- EXPECT_TRUE(file_util::CreateDirectory(dir2));
+ EXPECT_TRUE(base::CreateDirectory(dir2));
FilePath dir2inner = dir2.Append(FPL("inner"));
- EXPECT_TRUE(file_util::CreateDirectory(dir2inner));
+ EXPECT_TRUE(base::CreateDirectory(dir2inner));
// create the files
FilePath dir2file = dir2.Append(FPL("dir2file.txt"));
@@ -1870,13 +1870,13 @@
if (PathExists(data_dir)) {
ASSERT_TRUE(DeleteFile(data_dir, true));
}
- ASSERT_TRUE(file_util::CreateDirectory(data_dir));
+ ASSERT_TRUE(base::CreateDirectory(data_dir));
// Create a fresh, empty copy of this directory.
if (PathExists(data_dir)) {
ASSERT_TRUE(DeleteFile(data_dir, true));
}
- ASSERT_TRUE(file_util::CreateDirectory(data_dir));
+ ASSERT_TRUE(base::CreateDirectory(data_dir));
FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt")));
std::string data("hello");
@@ -1898,7 +1898,7 @@
if (PathExists(data_dir)) {
ASSERT_TRUE(DeleteFile(data_dir, true));
}
- ASSERT_TRUE(file_util::CreateDirectory(data_dir));
+ ASSERT_TRUE(base::CreateDirectory(data_dir));
FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt")));
std::string data("hello");
@@ -1930,7 +1930,7 @@
ASSERT_FALSE(PathExists(empty_dir));
- ASSERT_TRUE(file_util::CreateDirectory(empty_dir));
+ ASSERT_TRUE(base::CreateDirectory(empty_dir));
EXPECT_TRUE(base::IsDirectoryEmpty(empty_dir));
@@ -1962,10 +1962,10 @@
// |-> text_file_
base_dir_ = temp_dir_.path().AppendASCII("base_dir");
- ASSERT_TRUE(file_util::CreateDirectory(base_dir_));
+ ASSERT_TRUE(base::CreateDirectory(base_dir_));
sub_dir_ = base_dir_.AppendASCII("sub_dir");
- ASSERT_TRUE(file_util::CreateDirectory(sub_dir_));
+ ASSERT_TRUE(base::CreateDirectory(sub_dir_));
text_file_ = sub_dir_.AppendASCII("file.txt");
CreateTextFile(text_file_, L"This text file has some text in it.");
diff --git a/base/files/file_path_watcher_browsertest.cc b/base/files/file_path_watcher_browsertest.cc
index d42aab2..aed409c 100644
--- a/base/files/file_path_watcher_browsertest.cc
+++ b/base/files/file_path_watcher_browsertest.cc
@@ -339,7 +339,7 @@
scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(file, &watcher, delegate.get(), false));
- ASSERT_TRUE(file_util::CreateDirectory(dir));
+ ASSERT_TRUE(base::CreateDirectory(dir));
ASSERT_TRUE(WriteFile(file, "content"));
@@ -376,7 +376,7 @@
for (std::vector<std::string>::const_iterator d(dir_names.begin());
d != dir_names.end(); ++d) {
sub_path = sub_path.AppendASCII(*d);
- ASSERT_TRUE(file_util::CreateDirectory(sub_path));
+ ASSERT_TRUE(base::CreateDirectory(sub_path));
}
VLOG(1) << "Create File";
ASSERT_TRUE(WriteFile(file, "content"));
@@ -397,7 +397,7 @@
FilePathWatcher watcher;
FilePath dir(temp_dir_.path().AppendASCII("dir"));
FilePath file(dir.AppendASCII("file"));
- ASSERT_TRUE(file_util::CreateDirectory(dir));
+ ASSERT_TRUE(base::CreateDirectory(dir));
ASSERT_TRUE(WriteFile(file, "content"));
scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(file, &watcher, delegate.get(), false));
@@ -432,7 +432,7 @@
scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(dir, &watcher, delegate.get(), false));
- ASSERT_TRUE(file_util::CreateDirectory(dir));
+ ASSERT_TRUE(base::CreateDirectory(dir));
VLOG(1) << "Waiting for directory creation";
ASSERT_TRUE(WaitForEvents());
@@ -471,7 +471,7 @@
false));
// Setup a directory hierarchy.
- ASSERT_TRUE(file_util::CreateDirectory(subdir));
+ ASSERT_TRUE(base::CreateDirectory(subdir));
ASSERT_TRUE(WriteFile(file, "content"));
VLOG(1) << "Waiting for file creation";
ASSERT_TRUE(WaitForEvents());
@@ -492,7 +492,7 @@
ASSERT_TRUE(SetupWatch(dir, &watcher, delegate.get(), true));
// Main directory("dir") creation.
- ASSERT_TRUE(file_util::CreateDirectory(dir));
+ ASSERT_TRUE(base::CreateDirectory(dir));
ASSERT_TRUE(WaitForEvents());
// Create "$dir/file1".
@@ -502,7 +502,7 @@
// Create "$dir/subdir".
FilePath subdir(dir.AppendASCII("subdir"));
- ASSERT_TRUE(file_util::CreateDirectory(subdir));
+ ASSERT_TRUE(base::CreateDirectory(subdir));
ASSERT_TRUE(WaitForEvents());
// Create "$dir/subdir/subdir_file1".
@@ -512,7 +512,7 @@
// Create "$dir/subdir/subdir_child_dir".
FilePath subdir_child_dir(subdir.AppendASCII("subdir_child_dir"));
- ASSERT_TRUE(file_util::CreateDirectory(subdir_child_dir));
+ ASSERT_TRUE(base::CreateDirectory(subdir_child_dir));
ASSERT_TRUE(WaitForEvents());
// Create "$dir/subdir/subdir_child_dir/child_dir_file1".
@@ -559,7 +559,7 @@
FilePath dest_file(dest_subdir.AppendASCII("file"));
// Setup a directory hierarchy.
- ASSERT_TRUE(file_util::CreateDirectory(source_subdir));
+ ASSERT_TRUE(base::CreateDirectory(source_subdir));
ASSERT_TRUE(WriteFile(source_file, "content"));
scoped_ptr<TestDelegate> file_delegate(new TestDelegate(collector()));
@@ -683,7 +683,7 @@
FilePath linkfile(link_dir.AppendASCII("file"));
scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
// dir/file should exist.
- ASSERT_TRUE(file_util::CreateDirectory(dir));
+ ASSERT_TRUE(base::CreateDirectory(dir));
ASSERT_TRUE(WriteFile(file, "content"));
// Note that we are watching dir.lnk/file which doesn't exist yet.
ASSERT_TRUE(SetupWatch(linkfile, &watcher, delegate.get(), false));
@@ -717,7 +717,7 @@
// Note that we are watching dir.lnk/file.
ASSERT_TRUE(SetupWatch(linkfile, &watcher, delegate.get(), false));
- ASSERT_TRUE(file_util::CreateDirectory(dir));
+ ASSERT_TRUE(base::CreateDirectory(dir));
ASSERT_TRUE(WriteFile(file, "content"));
VLOG(1) << "Waiting for dir/file creation";
ASSERT_TRUE(WaitForEvents());
@@ -741,7 +741,7 @@
FilePath file(dir.AppendASCII("file"));
FilePath linkfile(link_dir.AppendASCII("file"));
scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
- ASSERT_TRUE(file_util::CreateDirectory(dir));
+ ASSERT_TRUE(base::CreateDirectory(dir));
ASSERT_TRUE(CreateSymbolicLink(dir, link_dir));
// Note that we are watching dir.lnk/file but the file doesn't exist yet.
ASSERT_TRUE(SetupWatch(linkfile, &watcher, delegate.get(), false));
@@ -812,8 +812,8 @@
FilePath test_dir2(test_dir1.AppendASCII("DirAttributesChangedDir2"));
FilePath test_file(test_dir2.AppendASCII("DirAttributesChangedFile"));
// Setup a directory hierarchy.
- ASSERT_TRUE(file_util::CreateDirectory(test_dir1));
- ASSERT_TRUE(file_util::CreateDirectory(test_dir2));
+ ASSERT_TRUE(base::CreateDirectory(test_dir1));
+ ASSERT_TRUE(base::CreateDirectory(test_dir2));
ASSERT_TRUE(WriteFile(test_file, "content"));
FilePathWatcher watcher;
diff --git a/base/files/file_util_proxy_unittest.cc b/base/files/file_util_proxy_unittest.cc
index 73ac8a6..7691d44 100644
--- a/base/files/file_util_proxy_unittest.cc
+++ b/base/files/file_util_proxy_unittest.cc
@@ -247,7 +247,7 @@
TEST_F(FileUtilProxyTest, GetFileInfo_Directory) {
// Setup.
- ASSERT_TRUE(file_util::CreateDirectory(test_path()));
+ ASSERT_TRUE(base::CreateDirectory(test_path()));
PlatformFileInfo expected_info;
file_util::GetFileInfo(test_path(), &expected_info);
diff --git a/base/files/scoped_temp_dir.cc b/base/files/scoped_temp_dir.cc
index 5624a06..b893b02 100644
--- a/base/files/scoped_temp_dir.cc
+++ b/base/files/scoped_temp_dir.cc
@@ -34,7 +34,7 @@
return false;
// If |base_path| does not exist, create it.
- if (!file_util::CreateDirectory(base_path))
+ if (!base::CreateDirectory(base_path))
return false;
// Create a new, uniquely named directory under |base_path|.
@@ -50,7 +50,7 @@
if (!path_.empty())
return false;
- if (!DirectoryExists(path) && !file_util::CreateDirectory(path))
+ if (!DirectoryExists(path) && !base::CreateDirectory(path))
return false;
path_ = path;
diff --git a/base/path_service.cc b/base/path_service.cc
index 89e58b2..f0a6a84 100644
--- a/base/path_service.cc
+++ b/base/path_service.cc
@@ -254,7 +254,7 @@
// this to the absolute path because on POSIX, MakeAbsoluteFilePath fails
// if called on a non-existent path.
if (!base::PathExists(file_path) &&
- !file_util::CreateDirectory(file_path))
+ !base::CreateDirectory(file_path))
return false;
}
diff --git a/base/test/launcher/test_results_tracker.cc b/base/test/launcher/test_results_tracker.cc
index 905b0f1..b2140da 100644
--- a/base/test/launcher/test_results_tracker.cc
+++ b/base/test/launcher/test_results_tracker.cc
@@ -130,7 +130,7 @@
LOG(WARNING) << "The output directory does not exist. "
<< "Creating the directory: " << dir_name.value();
// Create the directory if necessary (because the gtest does the same).
- if (!file_util::CreateDirectory(dir_name)) {
+ if (!base::CreateDirectory(dir_name)) {
LOG(ERROR) << "Failed to created directory " << dir_name.value();
return false;
}