Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3172)

Unified Diff: base/files/file_win.cc

Issue 2567383002: Add FLAG_CAN_DELETE_ON_CLOSE and DeleteOnClose for use on Windows. (Closed)
Patch Set: clang compile fix Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/files/file_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_win.cc
diff --git a/base/files/file_win.cc b/base/files/file_win.cc
index 20c8908375c9b77b8a49d363410072b3861a8fb5..acd3334f6afcd18a051c958bfcb587dc34516e3f 100644
--- a/base/files/file_win.cc
+++ b/base/files/file_win.cc
@@ -273,6 +273,12 @@ File File::Duplicate() const {
return other;
}
+bool File::DeleteOnClose(bool delete_on_close) {
+ FILE_DISPOSITION_INFO disposition = {delete_on_close ? TRUE : FALSE};
+ return ::SetFileInformationByHandle(GetPlatformFile(), FileDispositionInfo,
+ &disposition, sizeof(disposition)) != 0;
+}
+
// Static.
File::Error File::OSErrorToFileError(DWORD last_error) {
switch (last_error) {
@@ -359,6 +365,8 @@ void File::DoInitialize(const FilePath& path, uint32_t flags) {
access |= FILE_WRITE_ATTRIBUTES;
if (flags & FLAG_EXECUTE)
access |= GENERIC_EXECUTE;
+ if (flags & FLAG_CAN_DELETE_ON_CLOSE)
+ access |= DELETE;
DWORD sharing = (flags & FLAG_EXCLUSIVE_READ) ? 0 : FILE_SHARE_READ;
if (!(flags & FLAG_EXCLUSIVE_WRITE))
« no previous file with comments | « base/files/file_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698