Index: runtime/bin/file_android.cc |
diff --git a/runtime/bin/file_android.cc b/runtime/bin/file_android.cc |
index 21dcaa956b3501c971946c445746bbfbb0319273..2d7c99d1cba9cbc792afe3a96e86fec8ace110e3 100644 |
--- a/runtime/bin/file_android.cc |
+++ b/runtime/bin/file_android.cc |
@@ -166,11 +166,25 @@ bool File::CreateLink(const char* name, const char* target) { |
bool File::Delete(const char* name) { |
- int status = TEMP_FAILURE_RETRY(remove(name)); |
- if (status == -1) { |
- return false; |
+ File::Type type = File::GetType(name, true); |
+ if (type == kIsFile) { |
+ return TEMP_FAILURE_RETRY(unlink(name)) == 0; |
+ } else if (type == kIsDirectory) { |
+ errno = EISDIR; |
+ } else { |
+ errno = ENOENT; |
+ } |
+ return false; |
+} |
+ |
+ |
+bool File::DeleteLink(const char* name) { |
+ File::Type type = File::GetType(name, false); |
+ if (type == kIsLink) { |
+ return TEMP_FAILURE_RETRY(unlink(name)) == 0; |
} |
- return true; |
+ errno = EINVAL; |
+ return false; |
} |