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

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

Issue 11316102: Add utility methods to write the contents of a file as one operation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 1 month 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 | « no previous file | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/file.dart
diff --git a/sdk/lib/io/file.dart b/sdk/lib/io/file.dart
index 97fc18c9bcc106bb891365d5c056ec9f7c8d6fd1..7937aa0b35a70c787f0c2376aaf34c41f8129247 100644
--- a/sdk/lib/io/file.dart
+++ b/sdk/lib/io/file.dart
@@ -214,6 +214,60 @@ abstract class File {
List<String> readAsLinesSync([Encoding encoding = Encoding.UTF_8]);
/**
+ * Write a list of bytes to a file.
+ *
+ * Opens the file, writes the list of bytes to it, and closes the file.
+ * Returns a [:Future<File>:] that completes with this [File] object once
+ * the entire operation has completed.
+ *
+ * By default [writeAsBytes] creates the file for writing and truncates the
+ * file if it already exists. In order to append the bytes to an existing
+ * file pass [:FileMode.APPEND:] as the optional mode parameter.
+ */
+ Future<File> writeAsBytes(List<int> bytes, [FileMode mode = FileMode.WRITE]);
+
+ /**
+ * Synchronously write a list of bytes to a file.
+ *
+ * Opens the file, writes the list of bytes to it and closses the file.
+ *
+ * By default [writeAsBytesSync] creates the file for writing and truncates
+ * the file if it already exists. In order to append the bytes to an existing
+ * file pass [:FileMode.APPEND:] as the optional mode parameter.
+ */
+ void writeAsBytesSync(List<int> bytes, [FileMode mode = FileMode.WRITE]);
+
+ /**
+ * Write a string to a file.
+ *
+ * Opens the file, writes the string in the given encoding, and closes the
+ * file. Returns a [:Future<File>:] that completes with this [File] object
+ * once the entire operation has completed.
+ *
+ * By default [writeAsString] creates the file for writing and truncates the
+ * file if it already exists. In order to append the bytes to an existing
+ * file pass [:FileMode.APPEND:] as the optional mode parameter.
+ */
+ Future<File> writeAsString(String contents,
+ [Encoding encoding = Encoding.UTF_8,
+ FileMode mode = FileMode.WRITE]);
+
+ /**
+ * Synchronously write a string to a file.
+ *
+ * Opens the file, writes the string in the given encoding, and closes the
+ * file.
+ *
+ * By default [writeAsStringSync] creates the file for writing and
+ * truncates the file if it already exists. In order to append the bytes
+ * to an existing file pass [:FileMode.APPEND:] as the optional mode
+ * parameter.
+ */
+ void writeAsStringSync(String contents,
+ [Encoding encoding = Encoding.UTF_8,
+ FileMode mode = FileMode.WRITE]);
+
+ /**
* Get the name of the file.
*/
String get name;
« no previous file with comments | « no previous file | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698