summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-03 20:08:54 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-03 20:08:54 +0000
commit426d1c945bcb1a8479d92a7dd023c34cbbc7a261 (patch)
tree8b6d4ad435be865cc5eae1dacfc3e299436fb596 /base
parent425b55b976d5987b502d2e72e15befedbe2c9662 (diff)
downloadchromium_src-426d1c945bcb1a8479d92a7dd023c34cbbc7a261.zip
chromium_src-426d1c945bcb1a8479d92a7dd023c34cbbc7a261.tar.gz
chromium_src-426d1c945bcb1a8479d92a7dd023c34cbbc7a261.tar.bz2
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
Diffstat (limited to 'base')
-rw-r--r--base/base_paths_mac.mm2
-rw-r--r--base/file_util.cc8
-rw-r--r--base/file_util.h18
-rw-r--r--base/file_util_posix.cc41
-rw-r--r--base/file_util_unittest.cc116
-rw-r--r--base/file_util_win.cc34
-rw-r--r--base/files/file_path_watcher_browsertest.cc28
-rw-r--r--base/files/file_util_proxy_unittest.cc2
-rw-r--r--base/files/scoped_temp_dir.cc4
-rw-r--r--base/mac/mac_util_unittest.mm4
-rw-r--r--base/path_service.cc2
-rw-r--r--base/test/launcher/test_results_tracker.cc2
12 files changed, 130 insertions, 131 deletions
diff --git a/base/base_paths_mac.mm b/base/base_paths_mac.mm
index 5d4461c..86d6a80 100644
--- a/base/base_paths_mac.mm
+++ b/base/base_paths_mac.mm
@@ -71,7 +71,7 @@ bool PathProviderMac(int key, base::FilePath* result) {
#if defined(OS_IOS)
// On IOS, this directory does not exist unless it is created explicitly.
if (success && !base::PathExists(*result))
- success = file_util::CreateDirectory(*result);
+ success = base::CreateDirectory(*result);
#endif // defined(OS_IOS)
return success;
}
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 @@ FILE* CreateAndOpenTemporaryFile(FilePath* path) {
return CreateAndOpenTemporaryFileInDir(directory, path);
}
+bool CreateDirectory(const FilePath& full_path) {
+ return CreateDirectoryAndGetError(full_path, NULL);
+}
+
} // namespace base
// -----------------------------------------------------------------------------
@@ -171,10 +175,6 @@ using base::FileEnumerator;
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 @@ BASE_EXPORT bool CreateTemporaryDirInDir(const FilePath& base_dir,
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 bfdc9269..f566efb 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -588,27 +588,9 @@ bool CreateNewTempDirectory(const FilePath::StringType& prefix,
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 @@ bool CreateDirectoryAndGetError(const FilePath& full_path,
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 @@ TEST_F(FileUtilTest, FileAndDirectorySize) {
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 @@ TEST_F(FileUtilTest, FileAndDirectorySize) {
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 @@ TEST_F(FileUtilTest, NormalizeFilePathBasic) {
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 @@ TEST_F(FileUtilTest, NormalizeFilePathReparsePoints) {
// |-> 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 @@ TEST_F(FileUtilTest, NormalizeFilePathReparsePoints) {
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, DevicePathToDriveLetter) {
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 @@ TEST_F(FileUtilTest, CreateTemporaryFileInDirLongPathTest) {
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 @@ TEST_F(FileUtilTest, CreateTemporaryFileInDirLongPathTest) {
// 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 @@ TEST_F(FileUtilTest, CreateAndReadSymlinks) {
// 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 @@ TEST_F(FileUtilTest, NormalizeFilePathSymlinks) {
// 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 @@ TEST_F(FileUtilTest, ChangeDirectoryPermissionsAndEnumerate) {
// 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 @@ TEST_F(FileUtilTest, DeleteWildCard) {
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 @@ TEST_F(FileUtilTest, DeleteNonExistantWildCard) {
// 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, DeleteNonExistantWildCard) {
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 @@ TEST_F(FileUtilTest, DeleteDirNonRecursive) {
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, DeleteDirNonRecursive) {
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 @@ TEST_F(FileUtilTest, DeleteDirRecursive) {
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 @@ TEST_F(FileUtilTest, MoveFileDirExists) {
// 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 @@ TEST_F(FileUtilTest, MoveNew) {
// 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 @@ TEST_F(FileUtilTest, MoveExist) {
// 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 @@ TEST_F(FileUtilTest, MoveExist) {
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 @@ TEST_F(FileUtilTest, CopyDirectoryRecursivelyNew) {
// 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 @@ TEST_F(FileUtilTest, CopyDirectoryRecursivelyNew) {
// 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 @@ TEST_F(FileUtilTest, CopyDirectoryRecursivelyExists) {
// 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 @@ TEST_F(FileUtilTest, CopyDirectoryRecursivelyExists) {
// 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 @@ TEST_F(FileUtilTest, CopyDirectoryRecursivelyExists) {
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 @@ TEST_F(FileUtilTest, CopyDirectoryNew) {
// 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 @@ TEST_F(FileUtilTest, CopyDirectoryNew) {
// 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 @@ TEST_F(FileUtilTest, CopyDirectoryExists) {
// 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 @@ TEST_F(FileUtilTest, CopyDirectoryExists) {
// 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 @@ TEST_F(FileUtilTest, CopyDirectoryExists) {
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 @@ TEST_F(FileUtilTest, CopyFileWithCopyDirectoryRecursiveToExistingDirectory) {
// 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 @@ TEST_F(FileUtilTest, CopyDirectoryWithTrailingSeparators) {
// 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 @@ TEST_F(FileUtilTest, CopyFile) {
// 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 @@ TEST_F(FileUtilTest, CopyAndDeleteDirectoryTest) {
// 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 @@ TEST_F(FileUtilTest, CreateDirectoryTest) {
#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 @@ TEST_F(FileUtilTest, CreateDirectoryTest) {
// 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 @@ TEST_F(FileUtilTest, DetectDirectoryTest) {
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 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
// 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 @@ TEST_F(FileUtilTest, AppendToFile) {
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 @@ TEST_F(FileUtilTest, TouchFile) {
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 @@ TEST_F(FileUtilTest, IsDirectoryEmpty) {
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 @@ class VerifyPathControlledByUserTest : public FileUtilTest {
// |-> 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/file_util_win.cc b/base/file_util_win.cc
index ac35c74..be58630 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -178,7 +178,7 @@ bool CopyDirectory(const FilePath& from_path, const FilePath& 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)
- file_util::CreateDirectory(to_path);
+ CreateDirectory(to_path);
else
ShellCopy(from_path, to_path, false);
}
@@ -329,19 +329,9 @@ bool CreateNewTempDirectory(const FilePath::StringType& prefix,
return CreateTemporaryDirInDir(system_temp_dir, prefix, new_temp_path);
}
-} // namespace base
-
-// -----------------------------------------------------------------------------
-
-namespace file_util {
-
-using base::DirectoryExists;
-using base::FilePath;
-using base::kFileShareAll;
-
bool CreateDirectoryAndGetError(const FilePath& full_path,
- base::PlatformFileError* error) {
- base::ThreadRestrictions::AssertIOAllowed();
+ PlatformFileError* error) {
+ ThreadRestrictions::AssertIOAllowed();
// If the path exists, we've succeeded if it's a directory, failed otherwise.
const wchar_t* full_path_str = full_path.value().c_str();
@@ -355,7 +345,7 @@ bool CreateDirectoryAndGetError(const FilePath& full_path,
DLOG(WARNING) << "CreateDirectory(" << full_path_str << "), "
<< "conflicts with existing file.";
if (error) {
- *error = base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
+ *error = PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
}
return false;
}
@@ -368,14 +358,14 @@ bool CreateDirectoryAndGetError(const FilePath& full_path,
FilePath parent_path(full_path.DirName());
if (parent_path.value() == full_path.value()) {
if (error) {
- *error = base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ *error = PLATFORM_FILE_ERROR_NOT_FOUND;
}
return false;
}
if (!CreateDirectoryAndGetError(parent_path, error)) {
DLOG(WARNING) << "Failed to create one of the parent directories.";
if (error) {
- DCHECK(*error != base::PLATFORM_FILE_OK);
+ DCHECK(*error != PLATFORM_FILE_OK);
}
return false;
}
@@ -390,7 +380,7 @@ bool CreateDirectoryAndGetError(const FilePath& full_path,
return true;
} else {
if (error)
- *error = base::LastErrorToPlatformFileError(error_code);
+ *error = LastErrorToPlatformFileError(error_code);
DLOG(WARNING) << "Failed to create directory " << full_path_str
<< ", last error is " << error_code << ".";
return false;
@@ -400,6 +390,16 @@ bool CreateDirectoryAndGetError(const FilePath& full_path,
}
}
+} // namespace base
+
+// -----------------------------------------------------------------------------
+
+namespace file_util {
+
+using base::DirectoryExists;
+using base::FilePath;
+using base::kFileShareAll;
+
// TODO(rkc): Work out if we want to handle NTFS junctions here or not, handle
// them if we do decide to.
bool IsLink(const FilePath& file_path) {
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 @@ TEST_F(FilePathWatcherTest, NonExistentDirectory) {
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 @@ TEST_F(FilePathWatcherTest, DirectoryChain) {
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 @@ TEST_F(FilePathWatcherTest, DisappearingDirectory) {
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 @@ TEST_F(FilePathWatcherTest, WatchDirectory) {
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 @@ TEST_F(FilePathWatcherTest, MoveParent) {
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 @@ TEST_F(FilePathWatcherTest, RecursiveWatch) {
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 @@ TEST_F(FilePathWatcherTest, RecursiveWatch) {
// 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 @@ TEST_F(FilePathWatcherTest, RecursiveWatch) {
// 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 @@ TEST_F(FilePathWatcherTest, MoveChild) {
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 @@ TEST_F(FilePathWatcherTest, LinkedDirectoryPart1) {
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 @@ TEST_F(FilePathWatcherTest, LinkedDirectoryPart2) {
// 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 @@ TEST_F(FilePathWatcherTest, LinkedDirectoryPart3) {
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 @@ TEST_F(FilePathWatcherTest, DirAttributesChanged) {
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_File) {
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 @@ bool ScopedTempDir::CreateUniqueTempDirUnderPath(const FilePath& base_path) {
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 @@ bool ScopedTempDir::Set(const FilePath& path) {
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/mac/mac_util_unittest.mm b/base/mac/mac_util_unittest.mm
index 15ceca3..1b56814 100644
--- a/base/mac/mac_util_unittest.mm
+++ b/base/mac/mac_util_unittest.mm
@@ -220,7 +220,7 @@ TEST_F(MacUtilTest, TestRemoveQuarantineAttribute) {
ScopedTempDir temp_dir_;
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
FilePath dummy_folder_path = temp_dir_.path().Append("DummyFolder");
- ASSERT_TRUE(file_util::CreateDirectory(dummy_folder_path));
+ ASSERT_TRUE(base::CreateDirectory(dummy_folder_path));
const char* quarantine_str = "0000;4b392bb2;Chromium;|org.chromium.Chromium";
const char* file_path_str = dummy_folder_path.value().c_str();
EXPECT_EQ(0, setxattr(file_path_str, "com.apple.quarantine",
@@ -238,7 +238,7 @@ TEST_F(MacUtilTest, TestRemoveQuarantineAttributeTwice) {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
FilePath dummy_folder_path = temp_dir_.path().Append("DummyFolder");
const char* file_path_str = dummy_folder_path.value().c_str();
- ASSERT_TRUE(file_util::CreateDirectory(dummy_folder_path));
+ ASSERT_TRUE(base::CreateDirectory(dummy_folder_path));
EXPECT_EQ(-1, getxattr(file_path_str, "com.apple.quarantine", NULL, 0, 0, 0));
// No quarantine attribute to begin with, but RemoveQuarantineAttribute still
// succeeds because in the end the folder still doesn't have the quarantine
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 @@ bool PathService::OverrideAndCreateIfNeeded(int key,
// 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 @@ bool TestResultsTracker::Init(const CommandLine& command_line) {
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;
}