| Index: sdk/lib/io/file_impl.dart
|
| diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart
|
| index 5b4cddb0bd2b3f3490e00372834ba0ce5cb43581..d5e4cfc2950e1f203fa63a091a43800537f87a78 100644
|
| --- a/sdk/lib/io/file_impl.dart
|
| +++ b/sdk/lib/io/file_impl.dart
|
| @@ -556,18 +556,51 @@ class _File extends FileSystemEntity implements File {
|
| }
|
|
|
|
|
| -class _RandomAccessFile implements RandomAccessFile {
|
| +class _RandomAccessFile
|
| + extends Object with _ServiceObject
|
| + implements RandomAccessFile {
|
| + // Use default Map so we keep order.
|
| + static Map<int, _RandomAccessFile> _files = new Map<int, _RandomAccessFile>();
|
| +
|
| final String path;
|
| int _id;
|
| bool _asyncDispatched = false;
|
| SendPort _fileService;
|
|
|
| - _RandomAccessFile(this._id, this.path);
|
| +
|
| + _RandomAccessFile(this._id, this.path) {
|
| + _files[_serviceId] = this;
|
| + }
|
| +
|
| + String get _serviceTypePath => 'io/file/randomaccessfiles';
|
| + String get _serviceTypeName => 'RandomAccessFile';
|
| +
|
| + Map _toJSON(bool ref) {
|
| + var r = {
|
| + 'id': _servicePath,
|
| + 'type': _serviceType(ref),
|
| + 'name': '$path',
|
| + 'user_name': '$path',
|
| + };
|
| + if (ref) {
|
| + return r;
|
| + }
|
| + r['asyncDispatched'] = _asyncDispatched;
|
| + r['fd'] = _id;
|
| + return r;
|
| + }
|
| +
|
| + void _maybePerformCleanup() {
|
| + if (closed) {
|
| + _files.remove(_serviceId);
|
| + }
|
| + }
|
|
|
| Future<RandomAccessFile> close() {
|
| return _dispatch(_FILE_CLOSE, [_id], markClosed: true).then((result) {
|
| if (result != -1) {
|
| _id = result;
|
| + _maybePerformCleanup();
|
| return this;
|
| } else {
|
| throw new FileSystemException("Cannot close file", path);
|
| @@ -584,6 +617,7 @@ class _RandomAccessFile implements RandomAccessFile {
|
| throw new FileSystemException("Cannot close file", path);
|
| }
|
| _id = id;
|
| + _maybePerformCleanup();
|
| }
|
|
|
| Future<int> readByte() {
|
|
|