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

Unified Diff: runtime/bin/file.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.cc
diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc
index 5c54ed8579360eef0dc579d8ea9525e3c5aa0c1c..70833d11063a608da41e589ecc8b0927d1d7a8d8 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -488,6 +488,22 @@ void FUNCTION_NAME(File_Delete)(Dart_NativeArguments args) {
}
+void FUNCTION_NAME(File_DeleteLink)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ const char* str =
+ DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
+ bool result = File::DeleteLink(str);
+ if (result) {
+ Dart_SetReturnValue(args, Dart_NewBoolean(result));
+ } else {
+ Dart_Handle err = DartUtils::NewDartOSError();
+ if (Dart_IsError(err)) Dart_PropagateError(err);
+ Dart_SetReturnValue(args, err);
+ }
+ Dart_ExitScope();
+}
+
+
void FUNCTION_NAME(File_Directory)(Dart_NativeArguments args) {
Dart_EnterScope();
const char* str =
@@ -997,6 +1013,20 @@ static CObject* FileWriteListRequest(const CObjectArray& request) {
}
+static CObject* FileDeleteLinkRequest(const CObjectArray& request) {
+ if (request.Length() == 2 && request[1]->IsString()) {
+ CObjectString filename(request[1]);
+ bool result = File::DeleteLink(filename.CString());
+ if (result) {
+ return CObject::True();
+ } else {
+ return CObject::NewOSError();
+ }
+ }
+ return CObject::False();
+}
+
+
static void FileService(Dart_Port dest_port_id,
Dart_Port reply_port_id,
Dart_CObject* message) {
@@ -1063,6 +1093,9 @@ static void FileService(Dart_Port dest_port_id,
case File::kWriteListRequest:
response = FileWriteListRequest(request);
break;
+ case File::kDeleteLinkRequest:
+ response = FileDeleteLinkRequest(request);
+ break;
default:
UNREACHABLE();
}
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file_android.cc » ('j') | runtime/bin/file_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698