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

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

Issue 10872033: Change getters syntax in dart:io library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file.dart ('k') | runtime/bin/http.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 extends _BaseDataInputStream implements InputStream { 5 class _FileInputStream extends _BaseDataInputStream implements InputStream {
6 _FileInputStream(String name) 6 _FileInputStream(String name)
7 : _data = const [], 7 : _data = const [],
8 _position = 0, 8 _position = 0,
9 _filePosition = 0 { 9 _filePosition = 0 {
10 var file = new File(name); 10 var file = new File(name);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 _onNoPendingWrites(); 273 _onNoPendingWrites();
274 } 274 }
275 }); 275 });
276 writeListFuture.handleException((e) { 276 writeListFuture.handleException((e) {
277 outstandingWrites--; 277 outstandingWrites--;
278 _reportError(e); 278 _reportError(e);
279 return true; 279 return true;
280 }); 280 });
281 } 281 }
282 282
283 bool get closed() => _streamMarkedClosed; 283 bool get closed => _streamMarkedClosed;
284 284
285 RandomAccessFile _file; 285 RandomAccessFile _file;
286 286
287 // When this is set to true the stream is marked closed. When a 287 // When this is set to true the stream is marked closed. When a
288 // stream is marked closed no more data can be written. 288 // stream is marked closed no more data can be written.
289 bool _streamMarkedClosed = false; 289 bool _streamMarkedClosed = false;
290 290
291 // When this is set to true, the close callback has been scheduled and the 291 // When this is set to true, the close callback has been scheduled and the
292 // stream will be fully closed once it's called. 292 // stream will be fully closed once it's called.
293 bool _closeCallbackScheduled = false; 293 bool _closeCallbackScheduled = false;
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 }); 756 });
757 } 757 }
758 758
759 List<String> readAsLinesSync([Encoding encoding = Encoding.UTF_8]) { 759 List<String> readAsLinesSync([Encoding encoding = Encoding.UTF_8]) {
760 var decoder = _StringDecoders.decoder(encoding); 760 var decoder = _StringDecoders.decoder(encoding);
761 List<int> bytes = readAsBytesSync(); 761 List<int> bytes = readAsBytesSync();
762 decoder.write(bytes); 762 decoder.write(bytes);
763 return _getDecodedLines(decoder); 763 return _getDecodedLines(decoder);
764 } 764 }
765 765
766 String get name() => _name; 766 String get name => _name;
767 767
768 void _ensureFileService() { 768 void _ensureFileService() {
769 if (_fileService == null) { 769 if (_fileService == null) {
770 _fileService = _FileUtils.newServicePort(); 770 _fileService = _FileUtils.newServicePort();
771 } 771 }
772 } 772 }
773 773
774 final String _name; 774 final String _name;
775 775
776 SendPort _fileService; 776 SendPort _fileService;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 } 1132 }
1133 1133
1134 void flushSync() { 1134 void flushSync() {
1135 _checkNotClosed(); 1135 _checkNotClosed();
1136 var result = _FileUtils.flush(_id); 1136 var result = _FileUtils.flush(_id);
1137 if (result is OSError) { 1137 if (result is OSError) {
1138 throw new FileIOException("flush failed for file '$_name'", result); 1138 throw new FileIOException("flush failed for file '$_name'", result);
1139 } 1139 }
1140 } 1140 }
1141 1141
1142 String get name() => _name; 1142 String get name => _name;
1143 1143
1144 void _ensureFileService() { 1144 void _ensureFileService() {
1145 if (_fileService == null) { 1145 if (_fileService == null) {
1146 _fileService = _FileUtils.newServicePort(); 1146 _fileService = _FileUtils.newServicePort();
1147 } 1147 }
1148 } 1148 }
1149 1149
1150 bool get closed() => _id == 0; 1150 bool get closed => _id == 0;
1151 1151
1152 void _checkNotClosed() { 1152 void _checkNotClosed() {
1153 if (closed) { 1153 if (closed) {
1154 throw new FileIOException("File closed '$_name'"); 1154 throw new FileIOException("File closed '$_name'");
1155 } 1155 }
1156 } 1156 }
1157 1157
1158 Future _completeWithClosedException(Completer completer) { 1158 Future _completeWithClosedException(Completer completer) {
1159 new Timer(0, (t) { 1159 new Timer(0, (t) {
1160 completer.completeException( 1160 completer.completeException(
1161 new FileIOException("File closed '$_name'")); 1161 new FileIOException("File closed '$_name'"));
1162 }); 1162 });
1163 return completer.future; 1163 return completer.future;
1164 } 1164 }
1165 1165
1166 final String _name; 1166 final String _name;
1167 int _id; 1167 int _id;
1168 1168
1169 SendPort _fileService; 1169 SendPort _fileService;
1170 } 1170 }
OLDNEW
« no previous file with comments | « runtime/bin/file.dart ('k') | runtime/bin/http.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698