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

Unified Diff: runtime/bin/directory_android.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_android.cc
diff --git a/runtime/bin/directory_android.cc b/runtime/bin/directory_android.cc
index 1fb42cb1e700faa67952e8338c4c808fb39173b5..1b51fbd54132c42e0214fcd0fd6556b9e6235837 100644
--- a/runtime/bin/directory_android.cc
+++ b/runtime/bin/directory_android.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;
@@ -441,7 +445,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