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

Side by Side Diff: runtime/bin/file_win.cc

Issue 2050413002: Adds blocking file locks. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update docs and CHANGELOG Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <fcntl.h> // NOLINT 10 #include <fcntl.h> // NOLINT
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 131 }
132 int32_t length_low = Utils::Low32Bits(length); 132 int32_t length_low = Utils::Low32Bits(length);
133 int32_t length_high = Utils::High32Bits(length); 133 int32_t length_high = Utils::High32Bits(length);
134 134
135 BOOL rc; 135 BOOL rc;
136 switch (lock) { 136 switch (lock) {
137 case File::kLockUnlock: 137 case File::kLockUnlock:
138 rc = UnlockFileEx(handle, 0, length_low, length_high, &overlapped); 138 rc = UnlockFileEx(handle, 0, length_low, length_high, &overlapped);
139 break; 139 break;
140 case File::kLockShared: 140 case File::kLockShared:
141 case File::kLockExclusive: { 141 case File::kLockExclusive:
142 DWORD flags = LOCKFILE_FAIL_IMMEDIATELY; 142 case File::kLockBlockingShared:
143 if (lock == File::kLockExclusive) { 143 case File::kLockBlockingExclusive: {
144 DWORD flags = 0;
145 if ((lock == File::kLockShared) || (lock == File::kLockExclusive)) {
146 flags |= LOCKFILE_FAIL_IMMEDIATELY;
147 }
148 if ((lock == File::kLockExclusive) ||
149 (lock == File::kLockBlockingExclusive)) {
144 flags |= LOCKFILE_EXCLUSIVE_LOCK; 150 flags |= LOCKFILE_EXCLUSIVE_LOCK;
145 } 151 }
146 rc = LockFileEx(handle, flags, 0, 152 rc = LockFileEx(handle, flags, 0,
147 length_low, length_high, &overlapped); 153 length_low, length_high, &overlapped);
148 break; 154 break;
149 } 155 }
150 default: 156 default:
151 UNREACHABLE(); 157 UNREACHABLE();
152 } 158 }
153 return rc; 159 return rc;
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 return kIdentical; 699 return kIdentical;
694 } else { 700 } else {
695 return kDifferent; 701 return kDifferent;
696 } 702 }
697 } 703 }
698 704
699 } // namespace bin 705 } // namespace bin
700 } // namespace dart 706 } // namespace dart
701 707
702 #endif // defined(TARGET_OS_WINDOWS) 708 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/bin/file_macos.cc ('k') | sdk/lib/io/file.dart » ('j') | sdk/lib/io/file.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698