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

Unified Diff: runtime/bin/file_impl.dart

Issue 11345025: Use the encoding parameter for writeString on RandomAccessFile objects. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 | tests/standalone/io/file_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_impl.dart
diff --git a/runtime/bin/file_impl.dart b/runtime/bin/file_impl.dart
index 0aa31fb0291a2ec2602b7a9c2b002804d072e117..e3c9e21a5c33d427bd2bedaf61561f4c8508cbeb 100644
--- a/runtime/bin/file_impl.dart
+++ b/runtime/bin/file_impl.dart
@@ -902,32 +902,15 @@ class _RandomAccessFile extends _FileBase implements RandomAccessFile {
Future<RandomAccessFile> writeString(String string,
[Encoding encoding = Encoding.UTF_8]) {
- _ensureFileService();
- Completer<RandomAccessFile> completer = new Completer<RandomAccessFile>();
- if (closed) return _completeWithClosedException(completer);
- List request = new List(3);
- request[0] = _WRITE_STRING_REQUEST;
Søren Gjesse 2012/10/30 10:24:31 Shouldn't we fully remove the write string request
Mads Ager (google) 2012/10/30 11:34:05 Whoops! Good catch. Yes we should.
- request[1] = _id;
- request[2] = string;
- return _fileService.call(request).transform((response) {
- if (_isErrorResponse(response)) {
- throw _exceptionFromResponse(response,
- "writeString failed for file '$_name'");
- }
- return this;
- });
+ var data = _StringEncoders.encoder(encoding).encodeString(string);
+ return writeList(data, 0, data.length);
}
static _writeString(int id, String string) native "File_WriteString";
int writeStringSync(String string, [Encoding encoding = Encoding.UTF_8]) {
- _checkNotClosed();
- if (string is !String) throw new ArgumentError();
- var result = _writeString(_id, string);
- if (result is OSError) {
- throw new FileIOException("writeString failed for file '$_name'");
- }
- return result;
+ var data = _StringEncoders.encoder(encoding).encodeString(string);
+ return writeListSync(data, 0, data.length);
}
Future<int> position() {
« no previous file with comments | « no previous file | tests/standalone/io/file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698