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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 var r = { | 579 var r = { |
580 'id': _servicePath, | 580 'id': _servicePath, |
581 'type': _serviceType(ref), | 581 'type': _serviceType(ref), |
582 'name': '$path', | 582 'name': '$path', |
583 'user_name': '$path', | 583 'user_name': '$path', |
584 }; | 584 }; |
585 if (ref) { | 585 if (ref) { |
586 return r; | 586 return r; |
587 } | 587 } |
588 r['asyncDispatched'] = _asyncDispatched; | 588 r['asyncDispatched'] = _asyncDispatched; |
589 r['fd'] = _id; | 589 r['fd'] = _getFD(_id); |
590 return r; | 590 return r; |
591 } | 591 } |
592 | 592 |
593 void _maybePerformCleanup() { | 593 void _maybePerformCleanup() { |
594 if (closed) { | 594 if (closed) { |
595 _files.remove(_serviceId); | 595 _files.remove(_serviceId); |
596 } | 596 } |
597 } | 597 } |
598 | 598 |
| 599 external static int _getFD(int id); |
| 600 |
599 Future<RandomAccessFile> close() { | 601 Future<RandomAccessFile> close() { |
600 return _dispatch(_FILE_CLOSE, [_id], markClosed: true).then((result) { | 602 return _dispatch(_FILE_CLOSE, [_id], markClosed: true).then((result) { |
601 if (result != -1) { | 603 if (result != -1) { |
602 _id = result; | 604 _id = result; |
603 _maybePerformCleanup(); | 605 _maybePerformCleanup(); |
604 return this; | 606 return this; |
605 } else { | 607 } else { |
606 throw new FileSystemException("Cannot close file", path); | 608 throw new FileSystemException("Cannot close file", path); |
607 } | 609 } |
608 }); | 610 }); |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 void _checkAvailable() { | 935 void _checkAvailable() { |
934 if (_asyncDispatched) { | 936 if (_asyncDispatched) { |
935 throw new FileSystemException("An async operation is currently pending", | 937 throw new FileSystemException("An async operation is currently pending", |
936 path); | 938 path); |
937 } | 939 } |
938 if (closed) { | 940 if (closed) { |
939 throw new FileSystemException("File closed", path); | 941 throw new FileSystemException("File closed", path); |
940 } | 942 } |
941 } | 943 } |
942 } | 944 } |
OLD | NEW |