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

Unified Diff: runtime/bin/directory_win.cc

Issue 13771010: Fix recursive directory-deletion of top-level files/links. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Actually do the right thing. Created 7 years, 8 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_error_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 c8058540b0ab993189406a1011725ed015872e79..ff99f76385a60a1273d3bfac9987929303b5488e 100644
--- a/runtime/bin/directory_win.cc
+++ b/runtime/bin/directory_win.cc
@@ -263,17 +263,19 @@ static bool DeleteEntry(LPWIN32_FIND_DATAW find_file_data, PathBuffer* path) {
static bool DeleteRecursively(PathBuffer* path) {
+ DWORD attributes = GetFileAttributesW(path->data);
+ if ((attributes == INVALID_FILE_ATTRIBUTES)) {
+ return false;
+ }
// If the directory is a junction, it's pointing to some other place in the
// filesystem that we do not want to recurse into.
- DWORD attributes = GetFileAttributesW(path->data);
- if ((attributes != INVALID_FILE_ATTRIBUTES) &&
- (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
- if (IsBrokenLink(path->data)) {
- return false;
- } else {
- // Just delete the junction itself.
- return RemoveDirectoryW(path->data) != 0;
- }
+ if ((attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
+ // Just delete the junction itself.
+ return RemoveDirectoryW(path->data) != 0;
+ }
+ // If it's a file, remove it directly.
+ if ((attributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
+ return DeleteFile(L"", path);
}
if (!path->Add(L"\\*")) return false;
« no previous file with comments | « runtime/bin/directory_macos.cc ('k') | tests/standalone/io/directory_error_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698