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

Unified Diff: runtime/bin/directory_win.cc

Issue 11794048: Fix race condition in Directory.create. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « runtime/bin/directory_macos.cc ('k') | tests/standalone/io/directory_create_race_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_win.cc
diff --git a/runtime/bin/directory_win.cc b/runtime/bin/directory_win.cc
index 4d8c9fa8f1d02040f66a02776d57cc9eefc61ba8..9d8f6f31935d30691c4344acc8354d300dfef835 100644
--- a/runtime/bin/directory_win.cc
+++ b/runtime/bin/directory_win.cc
@@ -344,13 +344,14 @@ char* Directory::Current() {
bool Directory::Create(const char* dir_name) {
const wchar_t* system_name = StringUtils::Utf8ToWide(dir_name);
- // If the directory already exists and is a directory do not
- // attempt to create it again and treat it as a success.
- if (ExistsHelper(system_name) == EXISTS) {
+ int create_status = CreateDirectoryW(system_name, NULL);
+ // If the directory already existed, treat it as a success.
+ if (create_status == 0 &&
+ GetLastError() == ERROR_ALREADY_EXISTS &&
+ ExistsHelper(system_name) == EXISTS) {
free(const_cast<wchar_t*>(system_name));
return true;
}
- int create_status = CreateDirectoryW(system_name, NULL);
free(const_cast<wchar_t*>(system_name));
return (create_status != 0);
}
« no previous file with comments | « runtime/bin/directory_macos.cc ('k') | tests/standalone/io/directory_create_race_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698