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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 cancelOnError: cancelOnError); | 47 cancelOnError: cancelOnError); |
48 } | 48 } |
49 | 49 |
50 void _setupController() { | 50 void _setupController() { |
51 _controller = new StreamController<List<int>>(sync: true, | 51 _controller = new StreamController<List<int>>(sync: true, |
52 onListen: _start, | 52 onListen: _start, |
53 onPause: () => _paused = true, | 53 onPause: () => _paused = true, |
54 onResume: _resume, | 54 onResume: _resume, |
55 onCancel: () { | 55 onCancel: () { |
56 _unsubscribed = true; | 56 _unsubscribed = true; |
57 _closeFile(); | 57 return _closeFile(); |
58 }); | 58 }); |
59 } | 59 } |
60 | 60 |
61 Future _closeFile() { | 61 Future _closeFile() { |
62 if (_readInProgress) { | 62 if (_readInProgress) { |
63 return _closeCompleter.future; | 63 return _closeCompleter.future; |
64 } | 64 } |
65 if (_openedFile != null) { | 65 if (_openedFile != null) { |
66 _openedFile.close() | 66 _openedFile.close() |
67 .then(_closeCompleter.complete, | 67 .then(_closeCompleter.complete, |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 | 867 |
868 void _checkAvailable() { | 868 void _checkAvailable() { |
869 if (_asyncDispatched) { | 869 if (_asyncDispatched) { |
870 throw new FileSystemException("An async operation is currently pending", p
ath); | 870 throw new FileSystemException("An async operation is currently pending", p
ath); |
871 } | 871 } |
872 if (closed) { | 872 if (closed) { |
873 throw new FileSystemException("File closed", path); | 873 throw new FileSystemException("File closed", path); |
874 } | 874 } |
875 } | 875 } |
876 } | 876 } |
OLD | NEW |