| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 // Read the file in blocks of size 64k. | 7 // Read the file in blocks of size 64k. |
| 8 const int _BLOCK_SIZE = 64 * 1024; | 8 const int _BLOCK_SIZE = 64 * 1024; |
| 9 | 9 |
| 10 | 10 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } else { | 144 } else { |
| 145 _resume(); | 145 _resume(); |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 class _FileStreamConsumer extends StreamConsumer<List<int>, File> { | 150 class _FileStreamConsumer extends StreamConsumer<List<int>, File> { |
| 151 File _file; | 151 File _file; |
| 152 Future<RandomAccessFile> _openFuture; | 152 Future<RandomAccessFile> _openFuture; |
| 153 StreamSubscription _subscription; | 153 StreamSubscription _subscription; |
| 154 | |
| 155 | 154 |
| 156 _FileStreamConsumer(File this._file, FileMode mode) { | 155 _FileStreamConsumer(File this._file, FileMode mode) { |
| 157 _openFuture = _file.open(mode: mode); | 156 _openFuture = _file.open(mode: mode); |
| 158 } | 157 } |
| 159 | 158 |
| 160 _FileStreamConsumer.fromStdio(int fd) { | 159 _FileStreamConsumer.fromStdio(int fd) { |
| 161 assert(1 <= fd && fd <= 2); | 160 assert(1 <= fd && fd <= 2); |
| 162 _openFuture = new Future.immediate(_File._openStdioSync(fd)); | 161 _openFuture = new Future.immediate(_File._openStdioSync(fd)); |
| 163 } | 162 } |
| 164 | 163 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 const int _TRUNCATE_REQUEST = 9; | 212 const int _TRUNCATE_REQUEST = 9; |
| 214 const int _LENGTH_REQUEST = 10; | 213 const int _LENGTH_REQUEST = 10; |
| 215 const int _LENGTH_FROM_PATH_REQUEST = 11; | 214 const int _LENGTH_FROM_PATH_REQUEST = 11; |
| 216 const int _LAST_MODIFIED_REQUEST = 12; | 215 const int _LAST_MODIFIED_REQUEST = 12; |
| 217 const int _FLUSH_REQUEST = 13; | 216 const int _FLUSH_REQUEST = 13; |
| 218 const int _READ_BYTE_REQUEST = 14; | 217 const int _READ_BYTE_REQUEST = 14; |
| 219 const int _WRITE_BYTE_REQUEST = 15; | 218 const int _WRITE_BYTE_REQUEST = 15; |
| 220 const int _READ_REQUEST = 16; | 219 const int _READ_REQUEST = 16; |
| 221 const int _READ_LIST_REQUEST = 17; | 220 const int _READ_LIST_REQUEST = 17; |
| 222 const int _WRITE_LIST_REQUEST = 18; | 221 const int _WRITE_LIST_REQUEST = 18; |
| 223 const int _DELETE_LINK_REQUEST = 19; | 222 const int _CREATE_LINK_REQUEST = 19; |
| 223 const int _DELETE_LINK_REQUEST = 20; |
| 224 | 224 |
| 225 // Base class for _File and _RandomAccessFile with shared functions. | 225 // Base class for _File and _RandomAccessFile with shared functions. |
| 226 class _FileBase { | 226 class _FileBase { |
| 227 bool _isErrorResponse(response) { | 227 bool _isErrorResponse(response) { |
| 228 return response is List && response[0] != _SUCCESS_RESPONSE; | 228 return response is List && response[0] != _SUCCESS_RESPONSE; |
| 229 } | 229 } |
| 230 | 230 |
| 231 _exceptionFromResponse(response, String message) { | 231 _exceptionFromResponse(response, String message) { |
| 232 assert(_isErrorResponse(response)); | 232 assert(_isErrorResponse(response)); |
| 233 switch (response[_ERROR_RESPONSE_ERROR_TYPE]) { | 233 switch (response[_ERROR_RESPONSE_ERROR_TYPE]) { |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 new FileIOException("File closed '$_path'")); | 1054 new FileIOException("File closed '$_path'")); |
| 1055 }); | 1055 }); |
| 1056 return completer.future; | 1056 return completer.future; |
| 1057 } | 1057 } |
| 1058 | 1058 |
| 1059 final String _path; | 1059 final String _path; |
| 1060 int _id; | 1060 int _id; |
| 1061 | 1061 |
| 1062 SendPort _fileService; | 1062 SendPort _fileService; |
| 1063 } | 1063 } |
| OLD | NEW |