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

Unified Diff: runtime/bin/file.cc

Issue 17848003: dart:io | Add rename to Link (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix again Created 7 years, 6 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
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file.cc
diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc
index c687cdee632d148192474b38b8403336afac6982..1785674460d766c641d8a36fb1b65fc3085c403c 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -524,6 +524,24 @@ void FUNCTION_NAME(File_Rename)(Dart_NativeArguments args) {
}
+void FUNCTION_NAME(File_RenameLink)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ const char* old_path =
+ DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
+ const char* new_path =
+ DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1));
+ bool result = File::RenameLink(old_path, new_path);
+ 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_FullPath)(Dart_NativeArguments args) {
Dart_EnterScope();
const char* str =
@@ -1107,6 +1125,20 @@ static CObject* FileDeleteLinkRequest(const CObjectArray& request) {
}
+static CObject* FileRenameLinkRequest(const CObjectArray& request) {
+ if (request.Length() == 3 &&
+ request[1]->IsString() &&
+ request[2]->IsString()) {
+ CObjectString old_path(request[1]);
+ CObjectString new_path(request[2]);
+ bool completed = File::RenameLink(old_path.CString(), new_path.CString());
+ if (completed) return CObject::True();
+ return CObject::NewOSError();
+ }
+ return CObject::IllegalArgumentError();
+}
+
+
static CObject* FileLinkTargetRequest(const CObjectArray& request) {
if (request.Length() == 2 && request[1]->IsString()) {
CObjectString link_path(request[1]);
@@ -1248,6 +1280,9 @@ static void FileService(Dart_Port dest_port_id,
case File::kDeleteLinkRequest:
response = FileDeleteLinkRequest(request);
break;
+ case File::kRenameLinkRequest:
+ response = FileRenameLinkRequest(request);
+ break;
case File::kCreateLinkRequest:
response = FileCreateLinkRequest(request);
break;
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698