Index: sdk/lib/io/file_impl.dart |
diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart |
index ef467ac5577b40c05aab9fa7709fb07cfda4c0b2..57cfda6545d55486946c08df97aed2ddcb170af6 100644 |
--- a/sdk/lib/io/file_impl.dart |
+++ b/sdk/lib/io/file_impl.dart |
@@ -71,22 +71,14 @@ class _FileStream extends Stream<List<int>> { |
// Don't start a new read if one is already in progress. |
if (_readInProgress) return; |
_readInProgress = true; |
- _openedFile.length() |
- .then((length) { |
- if (_position >= length) { |
- _readInProgress = false; |
+ _openedFile.read(_BLOCK_SIZE) |
+ .then((block) { |
+ _readInProgress = false; |
+ if (block.length == 0) { |
if (!_unsubscribed) { |
_closeFile().then((_) { _controller.close(); }); |
_unsubscribed = true; |
} |
- return null; |
- } else { |
- return _openedFile.read(_BLOCK_SIZE); |
- } |
- }) |
- .then((block) { |
- _readInProgress = false; |
- if (block == null || _unsubscribed) { |
return; |
} |
_position += block.length; |