OLD | NEW |
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 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 "Invalid arguments to writeList for file '$_name'")); | 937 "Invalid arguments to writeList for file '$_name'")); |
938 }); | 938 }); |
939 return completer.future; | 939 return completer.future; |
940 } | 940 } |
941 if (closed) return _completeWithClosedException(completer); | 941 if (closed) return _completeWithClosedException(completer); |
942 | 942 |
943 List result; | 943 List result; |
944 try { | 944 try { |
945 result = | 945 result = |
946 _FileUtils.ensureFastAndSerializableBuffer(buffer, offset, bytes); | 946 _FileUtils.ensureFastAndSerializableBuffer(buffer, offset, bytes); |
947 } catch (var e) { | 947 } catch (e) { |
948 // Complete asynchronously so the user has a chance to setup | 948 // Complete asynchronously so the user has a chance to setup |
949 // handlers without getting exceptions when registering the | 949 // handlers without getting exceptions when registering the |
950 // then handler. | 950 // then handler. |
951 new Timer(0, (t) => completer.completeException(e)); | 951 new Timer(0, (t) => completer.completeException(e)); |
952 return completer.future; | 952 return completer.future; |
953 } | 953 } |
954 List outBuffer = result[0]; | 954 List outBuffer = result[0]; |
955 int outOffset = result[1]; | 955 int outOffset = result[1]; |
956 | 956 |
957 List request = new List(5); | 957 List request = new List(5); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |