| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 external static _rename(String oldPath, String newPath); | 301 external static _rename(String oldPath, String newPath); |
| 302 | 302 |
| 303 external static _renameLink(String oldPath, String newPath); | 303 external static _renameLink(String oldPath, String newPath); |
| 304 | 304 |
| 305 File renameSync(String newPath) { | 305 File renameSync(String newPath) { |
| 306 var result = _rename(path, newPath); | 306 var result = _rename(path, newPath); |
| 307 throwIfError(result, "Cannot rename file to '$newPath'", path); | 307 throwIfError(result, "Cannot rename file to '$newPath'", path); |
| 308 return new File(newPath); | 308 return new File(newPath); |
| 309 } | 309 } |
| 310 | 310 |
| 311 Directory get directory => super.parent; | |
| 312 | |
| 313 Future<RandomAccessFile> open({FileMode mode: FileMode.READ}) { | 311 Future<RandomAccessFile> open({FileMode mode: FileMode.READ}) { |
| 314 if (mode != FileMode.READ && | 312 if (mode != FileMode.READ && |
| 315 mode != FileMode.WRITE && | 313 mode != FileMode.WRITE && |
| 316 mode != FileMode.APPEND) { | 314 mode != FileMode.APPEND) { |
| 317 return new Future.error(new ArgumentError()); | 315 return new Future.error(new ArgumentError()); |
| 318 } | 316 } |
| 319 return _IOService.dispatch(_FILE_OPEN, [path, mode._mode]).then((response) { | 317 return _IOService.dispatch(_FILE_OPEN, [path, mode._mode]).then((response) { |
| 320 if (_isErrorResponse(response)) { | 318 if (_isErrorResponse(response)) { |
| 321 throw _exceptionFromResponse(response, "Cannot open file", path); | 319 throw _exceptionFromResponse(response, "Cannot open file", path); |
| 322 } | 320 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 external static int _openStdio(int fd); | 379 external static int _openStdio(int fd); |
| 382 | 380 |
| 383 static RandomAccessFile _openStdioSync(int fd) { | 381 static RandomAccessFile _openStdioSync(int fd) { |
| 384 var id = _openStdio(fd); | 382 var id = _openStdio(fd); |
| 385 if (id == 0) { | 383 if (id == 0) { |
| 386 throw new FileSystemException("Cannot open stdio file for: $fd"); | 384 throw new FileSystemException("Cannot open stdio file for: $fd"); |
| 387 } | 385 } |
| 388 return new _RandomAccessFile(id, ""); | 386 return new _RandomAccessFile(id, ""); |
| 389 } | 387 } |
| 390 | 388 |
| 391 Future<String> fullPath() => resolveSymbolicLinks(); | |
| 392 | |
| 393 String fullPathSync() => resolveSymbolicLinksSync(); | |
| 394 | |
| 395 Stream<List<int>> openRead([int start, int end]) { | 389 Stream<List<int>> openRead([int start, int end]) { |
| 396 return new _FileStream(path, start, end); | 390 return new _FileStream(path, start, end); |
| 397 } | 391 } |
| 398 | 392 |
| 399 IOSink openWrite({FileMode mode: FileMode.WRITE, | 393 IOSink openWrite({FileMode mode: FileMode.WRITE, |
| 400 Encoding encoding: UTF8}) { | 394 Encoding encoding: UTF8}) { |
| 401 if (mode != FileMode.WRITE && | 395 if (mode != FileMode.WRITE && |
| 402 mode != FileMode.APPEND) { | 396 mode != FileMode.APPEND) { |
| 403 throw new ArgumentError( | 397 throw new ArgumentError( |
| 404 "Wrong FileMode. Use FileMode.WRITE or FileMode.APPEND"); | 398 "Wrong FileMode. Use FileMode.WRITE or FileMode.APPEND"); |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 | 861 |
| 868 void _checkAvailable() { | 862 void _checkAvailable() { |
| 869 if (_asyncDispatched) { | 863 if (_asyncDispatched) { |
| 870 throw new FileSystemException("An async operation is currently pending", p
ath); | 864 throw new FileSystemException("An async operation is currently pending", p
ath); |
| 871 } | 865 } |
| 872 if (closed) { | 866 if (closed) { |
| 873 throw new FileSystemException("File closed", path); | 867 throw new FileSystemException("File closed", path); |
| 874 } | 868 } |
| 875 } | 869 } |
| 876 } | 870 } |
| OLD | NEW |