OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class _FileInputStream extends _BaseDataInputStream implements InputStream { | 7 class _FileInputStream extends _BaseDataInputStream implements InputStream { |
8 _FileInputStream(String name) | 8 _FileInputStream(String name) |
9 : _data = const [], | 9 : _data = const [], |
10 _position = 0, | 10 _position = 0, |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 | 478 |
479 | 479 |
480 external static _lengthFromName(String name); | 480 external static _lengthFromName(String name); |
481 | 481 |
482 int lengthSync() { | 482 int lengthSync() { |
483 var result = _lengthFromName(_name); | 483 var result = _lengthFromName(_name); |
484 throwIfError(result, "Cannot retrieve length of file '$_name'"); | 484 throwIfError(result, "Cannot retrieve length of file '$_name'"); |
485 return result; | 485 return result; |
486 } | 486 } |
487 | 487 |
488 Future<Date> lastModified() { | 488 Future<DateTime> lastModified() { |
489 _ensureFileService(); | 489 _ensureFileService(); |
490 List request = new List.fixedLength(2); | 490 List request = new List.fixedLength(2); |
491 request[0] = _LAST_MODIFIED_REQUEST; | 491 request[0] = _LAST_MODIFIED_REQUEST; |
492 request[1] = _name; | 492 request[1] = _name; |
493 return _fileService.call(request).then((response) { | 493 return _fileService.call(request).then((response) { |
494 if (_isErrorResponse(response)) { | 494 if (_isErrorResponse(response)) { |
495 throw _exceptionFromResponse(response, | 495 throw _exceptionFromResponse(response, |
496 "Cannot retrieve modification time " | 496 "Cannot retrieve modification time " |
497 "for file '$_name'"); | 497 "for file '$_name'"); |
498 } | 498 } |
499 return new Date.fromMillisecondsSinceEpoch(response); | 499 return new DateTime.fromMillisecondsSinceEpoch(response); |
500 }); | 500 }); |
501 } | 501 } |
502 | 502 |
503 external static _lastModified(String name); | 503 external static _lastModified(String name); |
504 | 504 |
505 Date lastModifiedSync() { | 505 DateTime lastModifiedSync() { |
506 var ms = _lastModified(name); | 506 var ms = _lastModified(name); |
507 throwIfError(ms, "Cannot retrieve modification time for file '$_name'"); | 507 throwIfError(ms, "Cannot retrieve modification time for file '$_name'"); |
508 return new Date.fromMillisecondsSinceEpoch(ms); | 508 return new DateTime.fromMillisecondsSinceEpoch(ms); |
509 } | 509 } |
510 | 510 |
511 external static _open(String name, int mode); | 511 external static _open(String name, int mode); |
512 | 512 |
513 RandomAccessFile openSync([FileMode mode = FileMode.READ]) { | 513 RandomAccessFile openSync([FileMode mode = FileMode.READ]) { |
514 if (mode != FileMode.READ && | 514 if (mode != FileMode.READ && |
515 mode != FileMode.WRITE && | 515 mode != FileMode.WRITE && |
516 mode != FileMode.APPEND) { | 516 mode != FileMode.APPEND) { |
517 throw new FileIOException("Unknown file mode. Use FileMode.READ, " | 517 throw new FileIOException("Unknown file mode. Use FileMode.READ, " |
518 "FileMode.WRITE or FileMode.APPEND."); | 518 "FileMode.WRITE or FileMode.APPEND."); |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 new FileIOException("File closed '$_name'")); | 1156 new FileIOException("File closed '$_name'")); |
1157 }); | 1157 }); |
1158 return completer.future; | 1158 return completer.future; |
1159 } | 1159 } |
1160 | 1160 |
1161 final String _name; | 1161 final String _name; |
1162 int _id; | 1162 int _id; |
1163 | 1163 |
1164 SendPort _fileService; | 1164 SendPort _fileService; |
1165 } | 1165 } |
OLD | NEW |