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

Unified Diff: runtime/bin/directory_macos.cc

Issue 13654002: Change how File/Directory/Link .delete works. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix windows error codes. 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
Index: runtime/bin/directory_macos.cc
diff --git a/runtime/bin/directory_macos.cc b/runtime/bin/directory_macos.cc
index 401f80cf94d89ef0549d3601cef4dd466eb90200..c59555a431238dcf181773d6caa9cc2c283f22d7 100644
--- a/runtime/bin/directory_macos.cc
+++ b/runtime/bin/directory_macos.cc
@@ -239,7 +239,11 @@ static bool DeleteRecursively(PathBuffer* path) {
if (TEMP_FAILURE_RETRY(lstat(path->data, &st)) == -1) {
return false;
} else if (S_ISLNK(st.st_mode)) {
- return (remove(path->data) == 0);
+ if (TEMP_FAILURE_RETRY(stat(path->data, &st)) == -1) {
+ return false;
+ } else if (S_ISDIR(st.st_mode)) {
+ return (unlink(path->data) == 0);
+ }
}
if (!path->Add(File::PathSeparator())) return false;
@@ -409,7 +413,11 @@ char* Directory::CreateTemp(const char* const_template) {
bool Directory::Delete(const char* dir_name, bool recursive) {
if (!recursive) {
- return (TEMP_FAILURE_RETRY(remove(dir_name)) == 0);
+ if (File::GetType(dir_name, false) == File::kIsLink &&
+ File::GetType(dir_name, true) == File::kIsDirectory) {
+ return (TEMP_FAILURE_RETRY(unlink(dir_name)) == 0);
+ }
+ return (TEMP_FAILURE_RETRY(rmdir(dir_name)) == 0);
} else {
PathBuffer path;
if (!path.Add(dir_name)) {

Powered by Google App Engine
This is Rietveld 408576698