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

Side by Side Diff: runtime/bin/file_impl.dart

Issue 8413034: New OutputStream interface (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@ Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file.dart ('k') | runtime/bin/output_stream.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class _FileInputStream implements FileInputStream { 5 class _FileInputStream implements FileInputStream {
6 _FileInputStream(File file) { 6 _FileInputStream(File file) {
7 _file = new File(file.name); 7 _file = new File(file.name);
8 _file.openSync(); 8 _file.openSync();
9 } 9 }
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 File _file; 66 File _file;
67 } 67 }
68 68
69 69
70 class _FileOutputStream implements FileOutputStream { 70 class _FileOutputStream implements FileOutputStream {
71 _FileOutputStream(File file) { 71 _FileOutputStream(File file) {
72 _file = new File(file.name); 72 _file = new File(file.name);
73 _file.openSync(true); 73 _file.openSync(true);
74 } 74 }
75 75
76 bool write(List<int> buffer, int offset, int len, void callback()) { 76 bool write(List<int> buffer) {
77 return _write(buffer, 0, buffer.length);
78 }
79
80 bool writeFrom(List<int> buffer, [int offset, int len]) {
81 return _write(buffer, offset, (len == null) ? buffer.length : len);
82 }
83
84 void end() {
85 _file.closeSync();
86 }
87
88 void close() {
89 _file.closeSync();
90 }
91
92 void set noPendingWriteHandler(void callback()) {
93 // TODO(sgjesse): How to handle this?
94 }
95
96 void set closeHandler(void callback()) {
97 // TODO(sgjesse): How to handle this?
98 }
99
100 void set errorHandler(void callback()) {
101 // TODO(sgjesse): How to handle this?
102 }
103
104 bool _write(List<int> buffer, int offset, int len) {
77 int bytesWritten = _file.writeListSync(buffer, offset, len); 105 int bytesWritten = _file.writeListSync(buffer, offset, len);
78
79 if (bytesWritten == len) { 106 if (bytesWritten == len) {
80 return true; 107 return true;
81 } else { 108 } else {
82 throw "FileOutputStream: write error"; 109 throw "FileOutputStream: write error";
83 } 110 }
84 } 111 }
85 112
86 void close() {
87 _file.closeSync();
88 }
89
90 File _file; 113 File _file;
91 } 114 }
92 115
93 116
94 // Class for encapsulating the native implementation of files. 117 // Class for encapsulating the native implementation of files.
95 class _File implements File { 118 class _File implements File {
96 // Constructor for file. 119 // Constructor for file.
97 _File(String this._name); 120 _File(String this._name);
98 121
99 void exists() { 122 void exists() {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 344
322 var _existsHandler; 345 var _existsHandler;
323 var _createHandler; 346 var _createHandler;
324 var _openHandler; 347 var _openHandler;
325 var _closeHandler; 348 var _closeHandler;
326 var _readByteHandler; 349 var _readByteHandler;
327 var _readListHandler; 350 var _readListHandler;
328 var _noPendingWriteHandler; 351 var _noPendingWriteHandler;
329 var _errorHandler; 352 var _errorHandler;
330 } 353 }
OLDNEW
« no previous file with comments | « runtime/bin/file.dart ('k') | runtime/bin/output_stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698