summaryrefslogtreecommitdiffstats
path: root/base/file_util_posix.cc
diff options
context:
space:
mode:
authormmoss@google.com <mmoss@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-11 16:09:11 +0000
committermmoss@google.com <mmoss@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-11 16:09:11 +0000
commit806b9c6f00c6d21259d049d21ebea52de9b47663 (patch)
tree4f5130957bf055d7371a5d6621063e6616cc340d /base/file_util_posix.cc
parente6f84f1438b160aab349b417bbd9eea34bd3568e (diff)
downloadchromium_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_posix.cc')
-rw-r--r--base/file_util_posix.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 201a2c0..f6beb57 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -111,6 +111,13 @@ bool PathExists(const std::wstring& path) {
return (stat64(WideToUTF8(path).c_str(), &file_info) == 0);
}
+bool DirectoryExists(const std::wstring& path) {
+ struct stat64 file_info;
+ if (stat64(WideToUTF8(path).c_str(), &file_info) == 0)
+ return S_ISDIR(file_info.st_mode);
+ return false;
+}
+
// TODO(erikkay): implement
#if 0
bool GetFileCreationLocalTimeFromHandle(int fd,
@@ -179,7 +186,7 @@ bool CreateDirectory(const std::wstring& full_path) {
path = *i;
else
AppendToPath(&path, *i);
- if (!PathExists(path)) {
+ if (!DirectoryExists(path)) {
if (mkdir(WideToUTF8(path).c_str(), 0777) != 0)
return false;
}
@@ -324,5 +331,3 @@ std::wstring FileEnumerator::Next() {
} // namespace file_util
-
-