summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authornhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-01 11:48:52 +0000
committernhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-01 11:48:52 +0000
commit307a825aeeda5d47bdd9ad1206496c1c2b878868 (patch)
tree5e9b23d11e06aa801bbf572e2ef8b379dca65527 /base
parent9a96389e66421f3c76b5349acaf78ab94eb322f1 (diff)
downloadchromium_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')
-rw-r--r--base/file_util.cc15
-rw-r--r--base/platform_file.h1
-rw-r--r--base/platform_file_win.cc2
3 files changed, 13 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);
diff --git a/base/platform_file.h b/base/platform_file.h
index a9708f4..1a71359 100644
--- a/base/platform_file.h
+++ b/base/platform_file.h
@@ -54,6 +54,7 @@ enum PlatformFileFlags {
PLATFORM_FILE_SHARE_DELETE = 1 << 15, // Used on Windows only
PLATFORM_FILE_TERMINAL_DEVICE = 1 << 16, // Serial port flags
+ PLATFORM_FILE_BACKUP_SEMANTICS = 1 << 17, // Used on Windows only
};
// PLATFORM_FILE_ERROR_ACCESS_DENIED is returned when a call fails because of
diff --git a/base/platform_file_win.cc b/base/platform_file_win.cc
index 272dfd1..b7861e6 100644
--- a/base/platform_file_win.cc
+++ b/base/platform_file_win.cc
@@ -70,6 +70,8 @@ PlatformFile CreatePlatformFile(const FilePath& name,
create_flags |= FILE_ATTRIBUTE_HIDDEN;
if (flags & PLATFORM_FILE_DELETE_ON_CLOSE)
create_flags |= FILE_FLAG_DELETE_ON_CLOSE;
+ if (flags & PLATFORM_FILE_BACKUP_SEMANTICS)
+ create_flags |= FILE_FLAG_BACKUP_SEMANTICS;
HANDLE file = CreateFile(name.value().c_str(), access, sharing, NULL,
disposition, create_flags, NULL);