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

Unified Diff: runtime/bin/file.dart

Issue 9452014: Implement File.{readAsBytes, readAsText, readAsLines}. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 10 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 | « no previous file | runtime/bin/file_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file.dart
diff --git a/runtime/bin/file.dart b/runtime/bin/file.dart
index 48687f6a91a0874c20ec03ee6248b4c13ba594a0..ee480b9bbe0ccc7817fa9a1b1d680449a9bb83fd 100644
--- a/runtime/bin/file.dart
+++ b/runtime/bin/file.dart
@@ -176,6 +176,54 @@ interface File default _File {
OutputStream openOutputStreamSync([FileMode mode]);
/**
+ * Read the entire file contents as a list of bytes. When the
+ * operation completes the [readAsBytesHandler] is called.
+ * The [errorHandler] is called if the operation fails.
+ */
+ void readAsBytes();
+
+ /**
+ * Synchronously read the entire file contents as a list of bytes.
+ */
+ List<int> readAsBytesSync();
+
+ /**
+ * Read the entire file contents as text using the give [encoding]
+ * ('UTF-8', 'ISO-8859-1', 'ASCII'). By default the encoding is
+ * 'UTF-8'.
+ *
+ * When the operation completes the [readAsTextHandler] is called
+ * with the resulting string. The [errorHandler] is called if the
+ * operation fails.
+ */
+ void readAsText([String encoding]);
+
+ /**
+ * Synchronously read the entire file contents as text using the
+ * give [encoding] ('UTF-8', 'ISO-8859-1', 'ASCII'). By default the
+ * encoding is 'UTF-8'.
+ */
+ String readAsTextSync([String encoding]);
+
+ /**
+ * Read the entire file contents as lines of text using the give
+ * [encoding] ('UTF-8', 'ISO-8859-1', 'ASCII'). By default the
+ * encoding is 'UTF-8'.
+ *
+ * When the operation completes the [readAsLinesHandler] is called
+ * with the resulting string. The [errorHandler] is called if the
+ * operation fails.
+ */
+ void readAsLines();
+
+ /**
+ * Synchronously read the entire file contents as lines of text
+ * using the give [encoding] ('UTF-8', 'ISO-8859-1', 'ASCII'). By
+ * default the encoding is 'UTF-8'.
+ */
+ List<String> readAsLinesSync([String encoding]);
+
+ /**
* Get the name of the file.
*/
String get name();
@@ -223,6 +271,24 @@ interface File default _File {
void set outputStreamHandler(void handler(OutputStream stream));
/**
+ * Set the handler that gets called when a [readAsBytes] operation
+ * completes.
+ */
+ void set readAsBytesHandler(void handler(List<int> bytes));
+
+ /**
+ * Set the handler that gets called when a [readAsText] operation
+ * completes.
+ */
+ void set readAsTextHandler(void handler(String text));
+
+ /**
+ * Set the handler that gets called when a [readAsLines] operation
+ * completes.
+ */
+ void set readAsLinesHandler(void handler(List<String> lines));
+
+ /**
* Sets the handler that gets called when a [fullPath] operation
* completes.
*/
« no previous file with comments | « no previous file | runtime/bin/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698