Index: runtime/bin/file_macos.cc |
diff --git a/runtime/bin/file_macos.cc b/runtime/bin/file_macos.cc |
index 301424b3daface22b3ad7cb6927934d3308de97c..a5af90428f16e822aa56cee5dd45491782fc7188 100644 |
--- a/runtime/bin/file_macos.cc |
+++ b/runtime/bin/file_macos.cc |
@@ -169,11 +169,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; |
} |