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 { | 311 Directory get directory => super.parent; |
312 _Path path = new _Path(this.path).directoryPath; | |
313 return new Directory(path.toNativePath()); | |
314 } | |
315 | 312 |
316 Future<RandomAccessFile> open({FileMode mode: FileMode.READ}) { | 313 Future<RandomAccessFile> open({FileMode mode: FileMode.READ}) { |
317 if (mode != FileMode.READ && | 314 if (mode != FileMode.READ && |
318 mode != FileMode.WRITE && | 315 mode != FileMode.WRITE && |
319 mode != FileMode.APPEND) { | 316 mode != FileMode.APPEND) { |
320 return new Future.error(new ArgumentError()); | 317 return new Future.error(new ArgumentError()); |
321 } | 318 } |
322 return _IOService.dispatch(_FILE_OPEN, [path, mode._mode]).then((response) { | 319 return _IOService.dispatch(_FILE_OPEN, [path, mode._mode]).then((response) { |
323 if (_isErrorResponse(response)) { | 320 if (_isErrorResponse(response)) { |
324 throw _exceptionFromResponse(response, "Cannot open file", path); | 321 throw _exceptionFromResponse(response, "Cannot open file", path); |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 | 867 |
871 void _checkAvailable() { | 868 void _checkAvailable() { |
872 if (_asyncDispatched) { | 869 if (_asyncDispatched) { |
873 throw new FileException("An async operation is currently pending", path); | 870 throw new FileException("An async operation is currently pending", path); |
874 } | 871 } |
875 if (closed) { | 872 if (closed) { |
876 throw new FileException("File closed", path); | 873 throw new FileException("File closed", path); |
877 } | 874 } |
878 } | 875 } |
879 } | 876 } |
OLD | NEW |