diff options
author | mmoss@google.com <mmoss@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-11 16:09:11 +0000 |
---|---|---|
committer | mmoss@google.com <mmoss@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-11 16:09:11 +0000 |
commit | 806b9c6f00c6d21259d049d21ebea52de9b47663 (patch) | |
tree | 4f5130957bf055d7371a5d6621063e6616cc340d /base/file_util_win.cc | |
parent | e6f84f1438b160aab349b417bbd9eea34bd3568e (diff) | |
download | chromium_src-806b9c6f00c6d21259d049d21ebea52de9b47663.zip chromium_src-806b9c6f00c6d21259d049d21ebea52de9b47663.tar.gz chromium_src-806b9c6f00c6d21259d049d21ebea52de9b47663.tar.bz2 |
CreateDirectory() should check if an existing path is actually a directory before skipping it. Also update a couple instances and comments to reflect current behaviour (see also http://codereview.chromium.org/1681).
Review URL: http://codereview.chromium.org/1709
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2060 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_win.cc')
-rw-r--r-- | base/file_util_win.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/base/file_util_win.cc b/base/file_util_win.cc index f5e39fa..f2822d1 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -176,6 +176,13 @@ bool PathIsWritable(const std::wstring& path) { return true; } +bool DirectoryExists(const std::wstring& path) { + DWORD fileattr = GetFileAttributes(path.c_str()); + if (fileattr != INVALID_FILE_ATTRIBUTES) + return (fileattr & FILE_ATTRIBUTE_DIRECTORY) != 0; + return false; +} + bool GetFileCreationLocalTimeFromHandle(HANDLE file_handle, LPSYSTEMTIME creation_time) { if (!file_handle) @@ -419,7 +426,7 @@ bool CreateNewTempDirectory(const std::wstring& prefix, } bool CreateDirectory(const std::wstring& full_path) { - if (PathExists(full_path)) + if (DirectoryExists(full_path)) return true; int err = SHCreateDirectoryEx(NULL, full_path.c_str(), NULL); return err == ERROR_SUCCESS; |