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

Unified Diff: runtime/bin/file_win.cc

Issue 13578003: Fix directory-listing, directory-deletion and file deletion, when links are involved. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use Link for Link removal. Created 7 years, 9 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_win.cc ('k') | tests/standalone/io/directory_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_win.cc
diff --git a/runtime/bin/file_win.cc b/runtime/bin/file_win.cc
index 8e618d310a6490245edda2b1657ac5e2f7886aa4..3780fca056c2adf2f827ef271da4ae4ecf839228 100644
--- a/runtime/bin/file_win.cc
+++ b/runtime/bin/file_win.cc
@@ -259,12 +259,19 @@ bool File::CreateLink(const char* utf8_name, const char* utf8_target) {
bool File::Delete(const char* name) {
const wchar_t* system_name = StringUtils::Utf8ToWide(name);
- int status = _wremove(system_name);
- free(const_cast<wchar_t*>(system_name));
- if (status == -1) {
- return false;
+ DWORD attributes = GetFileAttributesW(system_name);
+ if ((attributes != INVALID_FILE_ATTRIBUTES) &&
+ (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
+ // It's a junction(link), delete it.
+ return RemoveDirectoryW(system_name) != 0;
+ } else {
+ int status = _wremove(system_name);
+ free(const_cast<wchar_t*>(system_name));
+ if (status == -1) {
+ return false;
+ }
+ return true;
}
- return true;
}
« no previous file with comments | « runtime/bin/directory_win.cc ('k') | tests/standalone/io/directory_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698