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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
437 external static int _openStdio(int fd); | 437 external static int _openStdio(int fd); |
438 | 438 |
439 static RandomAccessFile _openStdioSync(int fd) { | 439 static RandomAccessFile _openStdioSync(int fd) { |
440 var id = _openStdio(fd); | 440 var id = _openStdio(fd); |
441 if (id == 0) { | 441 if (id == 0) { |
442 throw new FileException("Cannot open stdio file for: $fd"); | 442 throw new FileException("Cannot open stdio file for: $fd"); |
443 } | 443 } |
444 return new _RandomAccessFile(id, ""); | 444 return new _RandomAccessFile(id, ""); |
445 } | 445 } |
446 | 446 |
447 Future<String> fullPath() { | 447 Future<String> resolveSymbolicLinks() { |
448 _ensureFileService(); | 448 _ensureFileService(); |
449 List request = new List(2); | 449 List request = new List(2); |
450 request[0] = _FULL_PATH_REQUEST; | 450 request[0] = _RESOLVE_SYMBOLIC_LINKS_REQUEST; |
451 request[1] = path; | 451 request[1] = path; |
452 return _fileService.call(request).then((response) { | 452 return _fileService.call(request).then((response) { |
453 if (_isErrorResponse(response)) { | 453 if (_isErrorResponse(response)) { |
454 throw _exceptionFromResponse(response, | 454 throw _exceptionFromResponse(response, |
455 "Cannot retrieve full path", | 455 "Cannot resolve symbolic links", |
456 path); | 456 path); |
457 } | 457 } |
458 return response; | 458 return response; |
459 }); | 459 }); |
460 } | 460 } |
461 | 461 |
462 external static _fullPath(String path); | 462 Future<String> fullPath() => resolveSymbolicLinks(); |
Anders Johnsen
2013/09/09 12:24:48
This looks odd. Deprecate fullPath?
Søren Gjesse
2013/09/11 07:21:01
We should set a deadline for when fullPath is remo
Bill Hesse
2013/09/13 06:34:13
Deprecated, with deadline added.
| |
463 | 463 |
464 String fullPathSync() { | 464 external static _resolveSymbolicLinks(String path); |
465 var result = _fullPath(path); | 465 |
466 throwIfError(result, "Cannot retrieve full path", path); | 466 String resolveSymbolicLinksSync() { |
467 var result = _resolveSymbolicLinks(path); | |
468 throwIfError(result, "Cannot resolve symbolic links", path); | |
467 return result; | 469 return result; |
468 } | 470 } |
469 | 471 |
472 String fullPathSync() => resolveSymbolicLinksSync(); | |
473 | |
470 Stream<List<int>> openRead([int start, int end]) { | 474 Stream<List<int>> openRead([int start, int end]) { |
471 return new _FileStream(path, start, end); | 475 return new _FileStream(path, start, end); |
472 } | 476 } |
473 | 477 |
474 IOSink openWrite({FileMode mode: FileMode.WRITE, | 478 IOSink openWrite({FileMode mode: FileMode.WRITE, |
475 Encoding encoding: UTF8}) { | 479 Encoding encoding: UTF8}) { |
476 if (mode != FileMode.WRITE && | 480 if (mode != FileMode.WRITE && |
477 mode != FileMode.APPEND) { | 481 mode != FileMode.APPEND) { |
478 throw new ArgumentError( | 482 throw new ArgumentError( |
479 "Wrong FileMode. Use FileMode.WRITE or FileMode.APPEND"); | 483 "Wrong FileMode. Use FileMode.WRITE or FileMode.APPEND"); |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
983 void _checkNotClosed() { | 987 void _checkNotClosed() { |
984 if (closed) { | 988 if (closed) { |
985 throw new FileException("File closed", path); | 989 throw new FileException("File closed", path); |
986 } | 990 } |
987 } | 991 } |
988 | 992 |
989 Future _closedException() { | 993 Future _closedException() { |
990 return new Future.error(new FileException("File closed", path)); | 994 return new Future.error(new FileException("File closed", path)); |
991 } | 995 } |
992 } | 996 } |
OLD | NEW |