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

Unified Diff: runtime/bin/file_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/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;
}
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_patch.dart » ('j') | runtime/bin/file_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698