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

Unified Diff: runtime/bin/file_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/file_linux.cc
diff --git a/runtime/bin/file_linux.cc b/runtime/bin/file_linux.cc
index ceac63052bb2967dc5d10b1c465c74e7f7738ec1..8126ff98179e78227958069d1f0c2b09ebc6b4c0 100644
--- a/runtime/bin/file_linux.cc
+++ b/runtime/bin/file_linux.cc
@@ -167,11 +167,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_android.cc ('k') | runtime/bin/file_macos.cc » ('j') | runtime/bin/file_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698