diff options
author | nhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-01 11:48:52 +0000 |
---|---|---|
committer | nhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-01 11:48:52 +0000 |
commit | 307a825aeeda5d47bdd9ad1206496c1c2b878868 (patch) | |
tree | 5e9b23d11e06aa801bbf572e2ef8b379dca65527 /base/file_util.cc | |
parent | 9a96389e66421f3c76b5349acaf78ab94eb322f1 (diff) | |
download | chromium_src-307a825aeeda5d47bdd9ad1206496c1c2b878868.zip chromium_src-307a825aeeda5d47bdd9ad1206496c1c2b878868.tar.gz chromium_src-307a825aeeda5d47bdd9ad1206496c1c2b878868.tar.bz2 |
On Windows, current implementation fails touching directories because it cannot open directories without specific flag |FILE_FLAG_BACKUP_SEMANTICS|.
This patch makes it possible to touch them by setting the flag.
BUG=136490,137807
TEST=content_unittests --gtest_filter=\*MoveDirectory\*
Review URL: https://codereview.chromium.org/11198079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165338 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util.cc')
-rw-r--r-- | base/file_util.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/base/file_util.cc b/base/file_util.cc index abc7557..effee8a 100644 --- a/base/file_util.cc +++ b/base/file_util.cc @@ -203,11 +203,16 @@ bool IsDotDot(const FilePath& path) { bool TouchFile(const FilePath& path, const base::Time& last_accessed, const base::Time& last_modified) { - base::PlatformFile file = - base::CreatePlatformFile(path, - base::PLATFORM_FILE_OPEN | - base::PLATFORM_FILE_WRITE_ATTRIBUTES, - NULL, NULL); + int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE_ATTRIBUTES; + +#if defined(OS_WIN) + // On Windows, FILE_FLAG_BACKUP_SEMANTICS is needed to open a directory. + if (DirectoryExists(path)) + flags |= base::PLATFORM_FILE_BACKUP_SEMANTICS; +#endif // OS_WIN + + const base::PlatformFile file = + base::CreatePlatformFile(path, flags, NULL, NULL); if (file != base::kInvalidPlatformFileValue) { bool result = base::TouchPlatformFile(file, last_accessed, last_modified); base::ClosePlatformFile(file); |