diff options
author | huanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-17 20:42:40 +0000 |
---|---|---|
committer | huanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-17 20:42:40 +0000 |
commit | 89b9ae090d3d32dc5462e3c1d15b1a5d67f63e6a (patch) | |
tree | ef9962f91283d24ea61cfd780eda05e82544d640 | |
parent | a1b508bd812fd58321587869d1ba94e5994756a4 (diff) | |
download | chromium_src-89b9ae090d3d32dc5462e3c1d15b1a5d67f63e6a.zip chromium_src-89b9ae090d3d32dc5462e3c1d15b1a5d67f63e6a.tar.gz chromium_src-89b9ae090d3d32dc5462e3c1d15b1a5d67f63e6a.tar.bz2 |
Fix a regression introduced by r33225.
On windows, if CreateDirectory is called with an path on an
inaccessible drive, it will enter an infinite loop.
BUG=30415
TEST=base_unittests.exe --gtest_filter=FileUtilTest.CreateDirectoryTest
Review URL: http://codereview.chromium.org/500075
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34871 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/file_util_unittest.cc | 9 | ||||
-rw-r--r-- | base/file_util_win.cc | 6 |
2 files changed, 14 insertions, 1 deletions
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc index 0b47b231..200c386 100644 --- a/base/file_util_unittest.cc +++ b/base/file_util_unittest.cc @@ -1156,6 +1156,15 @@ TEST_F(FileUtilTest, CreateDirectoryTest) { EXPECT_TRUE(file_util::CreateDirectory( FilePath(FilePath::kCurrentDirectory))); EXPECT_TRUE(file_util::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 (!file_util::PathExists(invalid_drive)) { + EXPECT_FALSE(file_util::CreateDirectory(invalid_path)); + } +#endif } TEST_F(FileUtilTest, DetectDirectoryTest) { diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 6dfc049..b7424c0 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -528,7 +528,11 @@ bool CreateDirectory(const FilePath& full_path) { // Attempt to create the parent recursively. This will immediately return // true if it already exists, otherwise will create all required parent // directories starting with the highest-level missing parent. - if (!CreateDirectory(full_path.DirName())) { + FilePath parent_path(full_path.DirName()); + if (parent_path.value() == full_path.value()) { + return false; + } + if (!CreateDirectory(parent_path)) { DLOG(WARNING) << "Failed to create one of the parent directories."; return false; } |