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

Unified Diff: runtime/bin/file.cc

Issue 105133004: Add File.copy(Sync) to dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix permissions. Created 7 years 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 f0205fb8b5275af344212bbdd5feae9787cf7353..61b408f7e394ee927428f26c314a76951ee95acf 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -503,6 +503,22 @@ void FUNCTION_NAME(File_RenameLink)(Dart_NativeArguments args) {
}
+void FUNCTION_NAME(File_Copy)(Dart_NativeArguments args) {
+ const char* old_path =
+ DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
+ const char* new_path =
+ DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1));
+ bool result = File::Copy(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);
+ }
+}
+
+
void FUNCTION_NAME(File_ResolveSymbolicLinks)(Dart_NativeArguments args) {
const char* str =
DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
@@ -706,6 +722,20 @@ CObject* File::RenameRequest(const CObjectArray& request) {
}
+CObject* File::CopyRequest(const CObjectArray& request) {
+ if (request.Length() == 2 &&
+ request[0]->IsString() &&
+ request[1]->IsString()) {
+ CObjectString old_path(request[0]);
+ CObjectString new_path(request[1]);
+ bool completed = File::Copy(old_path.CString(), new_path.CString());
+ if (completed) return CObject::True();
+ return CObject::NewOSError();
+ }
+ return CObject::IllegalArgumentError();
+}
+
+
CObject* File::ResolveSymbolicLinksRequest(const CObjectArray& request) {
if (request.Length() == 1 && request[0]->IsString()) {
CObjectString filename(request[0]);
« 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