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

Unified Diff: runtime/bin/directory_linux.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_linux.cc
diff --git a/runtime/bin/directory_linux.cc b/runtime/bin/directory_linux.cc
index a316633d8e5b76fccfa913b472c670a19c3792c1..28b26a484e5129b6c3802c652fbaeb47282d2b27 100644
--- a/runtime/bin/directory_linux.cc
+++ b/runtime/bin/directory_linux.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