diff options
Diffstat (limited to 'base')
-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; } |