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

Unified Diff: sdk/lib/io/file_impl.dart

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 | « sdk/lib/io/file.dart ('k') | sdk/lib/io/io_service.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/file_impl.dart
diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart
index cb1efe3fd1577bcf56b387786376fafc45dc72f8..fcf2f5eaac9a0f90aa6886ef479422edd477d532 100644
--- a/sdk/lib/io/file_impl.dart
+++ b/sdk/lib/io/file_impl.dart
@@ -327,6 +327,24 @@ class _File extends FileSystemEntity implements File {
return new File(newPath);
}
+ Future<File> copy(String newPath) {
+ return _IOService.dispatch(_FILE_COPY, [path, newPath]).then((response) {
+ if (_isErrorResponse(response)) {
+ throw _exceptionFromResponse(
+ response, "Cannot copy file to '$newPath'", path);
+ }
+ return new File(newPath);
+ });
+ }
+
+ external static _copy(String oldPath, String newPath);
+
+ File copySync(String newPath) {
+ var result = _copy(path, newPath);
+ throwIfError(result, "Cannot copy file to '$newPath'", path);
+ return new File(newPath);
+ }
+
Future<RandomAccessFile> open({FileMode mode: FileMode.READ}) {
if (mode != FileMode.READ &&
mode != FileMode.WRITE &&
« no previous file with comments | « sdk/lib/io/file.dart ('k') | sdk/lib/io/io_service.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698