| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 return _openFuture.then((openedFile) => openedFile.close()); | 197 return _openFuture.then((openedFile) => openedFile.close()); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 | 200 |
| 201 | 201 |
| 202 const int _EXISTS_REQUEST = 0; | 202 const int _EXISTS_REQUEST = 0; |
| 203 const int _CREATE_REQUEST = 1; | 203 const int _CREATE_REQUEST = 1; |
| 204 const int _DELETE_REQUEST = 2; | 204 const int _DELETE_REQUEST = 2; |
| 205 const int _RENAME_REQUEST = 3; | 205 const int _RENAME_REQUEST = 3; |
| 206 const int _OPEN_REQUEST = 4; | 206 const int _OPEN_REQUEST = 4; |
| 207 const int _FULL_PATH_REQUEST = 5; | 207 const int _RESOLVE_SYMBOLIC_LINKS_REQUEST = 5; |
| 208 const int _CLOSE_REQUEST = 6; | 208 const int _CLOSE_REQUEST = 6; |
| 209 const int _POSITION_REQUEST = 7; | 209 const int _POSITION_REQUEST = 7; |
| 210 const int _SET_POSITION_REQUEST = 8; | 210 const int _SET_POSITION_REQUEST = 8; |
| 211 const int _TRUNCATE_REQUEST = 9; | 211 const int _TRUNCATE_REQUEST = 9; |
| 212 const int _LENGTH_REQUEST = 10; | 212 const int _LENGTH_REQUEST = 10; |
| 213 const int _LENGTH_FROM_PATH_REQUEST = 11; | 213 const int _LENGTH_FROM_PATH_REQUEST = 11; |
| 214 const int _LAST_MODIFIED_REQUEST = 12; | 214 const int _LAST_MODIFIED_REQUEST = 12; |
| 215 const int _FLUSH_REQUEST = 13; | 215 const int _FLUSH_REQUEST = 13; |
| 216 const int _READ_BYTE_REQUEST = 14; | 216 const int _READ_BYTE_REQUEST = 14; |
| 217 const int _WRITE_BYTE_REQUEST = 15; | 217 const int _WRITE_BYTE_REQUEST = 15; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 external static int _openStdio(int fd); | 439 external static int _openStdio(int fd); |
| 440 | 440 |
| 441 static RandomAccessFile _openStdioSync(int fd) { | 441 static RandomAccessFile _openStdioSync(int fd) { |
| 442 var id = _openStdio(fd); | 442 var id = _openStdio(fd); |
| 443 if (id == 0) { | 443 if (id == 0) { |
| 444 throw new FileException("Cannot open stdio file for: $fd"); | 444 throw new FileException("Cannot open stdio file for: $fd"); |
| 445 } | 445 } |
| 446 return new _RandomAccessFile(id, ""); | 446 return new _RandomAccessFile(id, ""); |
| 447 } | 447 } |
| 448 | 448 |
| 449 Future<String> fullPath() { | 449 Future<String> fullPath() => resolveSymbolicLinks(); |
| 450 _ensureFileService(); | |
| 451 List request = new List(2); | |
| 452 request[0] = _FULL_PATH_REQUEST; | |
| 453 request[1] = path; | |
| 454 return _fileService.call(request).then((response) { | |
| 455 if (_isErrorResponse(response)) { | |
| 456 throw _exceptionFromResponse(response, | |
| 457 "Cannot retrieve full path", | |
| 458 path); | |
| 459 } | |
| 460 return response; | |
| 461 }); | |
| 462 } | |
| 463 | 450 |
| 464 external static _fullPath(String path); | 451 String fullPathSync() => resolveSymbolicLinksSync(); |
| 465 | |
| 466 String fullPathSync() { | |
| 467 var result = _fullPath(path); | |
| 468 throwIfError(result, "Cannot retrieve full path", path); | |
| 469 return result; | |
| 470 } | |
| 471 | 452 |
| 472 Stream<List<int>> openRead([int start, int end]) { | 453 Stream<List<int>> openRead([int start, int end]) { |
| 473 return new _FileStream(path, start, end); | 454 return new _FileStream(path, start, end); |
| 474 } | 455 } |
| 475 | 456 |
| 476 IOSink openWrite({FileMode mode: FileMode.WRITE, | 457 IOSink openWrite({FileMode mode: FileMode.WRITE, |
| 477 Encoding encoding: UTF8}) { | 458 Encoding encoding: UTF8}) { |
| 478 if (mode != FileMode.WRITE && | 459 if (mode != FileMode.WRITE && |
| 479 mode != FileMode.APPEND) { | 460 mode != FileMode.APPEND) { |
| 480 throw new ArgumentError( | 461 throw new ArgumentError( |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 void _checkNotClosed() { | 980 void _checkNotClosed() { |
| 1000 if (closed) { | 981 if (closed) { |
| 1001 throw new FileException("File closed", path); | 982 throw new FileException("File closed", path); |
| 1002 } | 983 } |
| 1003 } | 984 } |
| 1004 | 985 |
| 1005 Future _closedException() { | 986 Future _closedException() { |
| 1006 return new Future.error(new FileException("File closed", path)); | 987 return new Future.error(new FileException("File closed", path)); |
| 1007 } | 988 } |
| 1008 } | 989 } |
| OLD | NEW |