| Index: runtime/bin/file.cc
|
| diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc
|
| index a971f961554dc29db234a15325e4b8ff9ae0d5f5..87fc2c1da57c582fb784a6c9ff4e57b2bd655198 100644
|
| --- a/runtime/bin/file.cc
|
| +++ b/runtime/bin/file.cc
|
| @@ -506,6 +506,24 @@ void FUNCTION_NAME(File_DeleteLink)(Dart_NativeArguments args) {
|
| }
|
|
|
|
|
| +void FUNCTION_NAME(File_Rename)(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::Rename(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 =
|
| @@ -707,6 +725,20 @@ static CObject* FileDeleteRequest(const CObjectArray& request) {
|
| }
|
|
|
|
|
| +static CObject* FileRenameRequest(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::Rename(old_path.CString(), new_path.CString());
|
| + if (completed) return CObject::True();
|
| + return CObject::NewOSError();
|
| + }
|
| + return CObject::IllegalArgumentError();
|
| +}
|
| +
|
| +
|
| static CObject* FileFullPathRequest(const CObjectArray& request) {
|
| if (request.Length() == 2 && request[1]->IsString()) {
|
| CObjectString filename(request[1]);
|
| @@ -1168,6 +1200,9 @@ static void FileService(Dart_Port dest_port_id,
|
| case File::kDeleteRequest:
|
| response = FileDeleteRequest(request);
|
| break;
|
| + case File::kRenameRequest:
|
| + response = FileRenameRequest(request);
|
| + break;
|
| case File::kFullPathRequest:
|
| response = FileFullPathRequest(request);
|
| break;
|
|
|