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

Unified Diff: runtime/bin/directory_macos.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_linux.cc ('k') | runtime/bin/directory_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_macos.cc
diff --git a/runtime/bin/directory_macos.cc b/runtime/bin/directory_macos.cc
index c59555a431238dcf181773d6caa9cc2c283f22d7..b1ba2d9fa6b98e9485d2f644f857d95c33fc753b 100644
--- a/runtime/bin/directory_macos.cc
+++ b/runtime/bin/directory_macos.cc
@@ -221,7 +221,7 @@ static bool ListRecursively(PathBuffer* path,
static bool DeleteFile(char* file_name,
PathBuffer* path) {
- return path->Add(file_name) && remove(path->data) == 0;
+ return path->Add(file_name) && unlink(path->data) == 0;
}
@@ -235,15 +235,12 @@ static bool DeleteDir(char* dir_name,
static bool DeleteRecursively(PathBuffer* path) {
// Do not recurse into links for deletion. Instead delete the link.
+ // If it's a file, delete it.
struct stat st;
if (TEMP_FAILURE_RETRY(lstat(path->data, &st)) == -1) {
return false;
- } else if (S_ISLNK(st.st_mode)) {
- if (TEMP_FAILURE_RETRY(stat(path->data, &st)) == -1) {
- return false;
- } else if (S_ISDIR(st.st_mode)) {
- return (unlink(path->data) == 0);
- }
+ } else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
+ return (unlink(path->data) == 0);
}
if (!path->Add(File::PathSeparator())) return false;
« no previous file with comments | « runtime/bin/directory_linux.cc ('k') | runtime/bin/directory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698