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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } catch (e, stackTrace) { | 201 } catch (e, stackTrace) { |
202 error(e, stackTrace); | 202 error(e, stackTrace); |
203 } | 203 } |
204 }, | 204 }, |
205 onDone: () { | 205 onDone: () { |
206 completer.complete(_file); | 206 completer.complete(_file); |
207 }, | 207 }, |
208 onError: error, | 208 onError: error, |
209 cancelOnError: true); | 209 cancelOnError: true); |
210 }) | 210 }) |
211 .catchError((e) { | 211 .catchError(completer.completeError); |
212 completer.completeError(e); | |
213 }); | |
214 return completer.future; | 212 return completer.future; |
215 } | 213 } |
216 | 214 |
217 Future<File> close() => | 215 Future<File> close() => |
218 _openFuture.then((openedFile) => openedFile.close()); | 216 _openFuture.then((openedFile) => openedFile.close()); |
219 } | 217 } |
220 | 218 |
221 | 219 |
222 // Class for encapsulating the native implementation of files. | 220 // Class for encapsulating the native implementation of files. |
223 class _File extends FileSystemEntity implements File { | 221 class _File extends FileSystemEntity implements File { |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 void _checkAvailable() { | 1042 void _checkAvailable() { |
1045 if (_asyncDispatched) { | 1043 if (_asyncDispatched) { |
1046 throw new FileSystemException("An async operation is currently pending", | 1044 throw new FileSystemException("An async operation is currently pending", |
1047 path); | 1045 path); |
1048 } | 1046 } |
1049 if (closed) { | 1047 if (closed) { |
1050 throw new FileSystemException("File closed", path); | 1048 throw new FileSystemException("File closed", path); |
1051 } | 1049 } |
1052 } | 1050 } |
1053 } | 1051 } |
OLD | NEW |