| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 throwIfError(result, "Cannot check existence of file", path); | 249 throwIfError(result, "Cannot check existence of file", path); |
| 250 return result; | 250 return result; |
| 251 } | 251 } |
| 252 | 252 |
| 253 File get absolute => new File(_absolutePath); | 253 File get absolute => new File(_absolutePath); |
| 254 | 254 |
| 255 Future<FileStat> stat() => FileStat.stat(path); | 255 Future<FileStat> stat() => FileStat.stat(path); |
| 256 | 256 |
| 257 FileStat statSync() => FileStat.statSync(path); | 257 FileStat statSync() => FileStat.statSync(path); |
| 258 | 258 |
| 259 Future<File> create() { | 259 Future<File> create({bool recursive: false}) { |
| 260 return _IOService.dispatch(_FILE_CREATE, [path]).then((response) { | 260 return (recursive ? parent.create(recursive: true) |
| 261 if (_isErrorResponse(response)) { | 261 : new Future.value(null)) |
| 262 throw _exceptionFromResponse(response, "Cannot create file", path); | 262 .then((_) => _IOService.dispatch(_FILE_CREATE, [path])) |
| 263 } | 263 .then((response) { |
| 264 return this; | 264 if (_isErrorResponse(response)) { |
| 265 }); | 265 throw _exceptionFromResponse(response, "Cannot create file", path); |
| 266 } |
| 267 return this; |
| 268 }); |
| 266 } | 269 } |
| 267 | 270 |
| 268 external static _create(String path); | 271 external static _create(String path); |
| 269 | 272 |
| 270 external static _createLink(String path, String target); | 273 external static _createLink(String path, String target); |
| 271 | 274 |
| 272 external static _linkTarget(String path); | 275 external static _linkTarget(String path); |
| 273 | 276 |
| 274 void createSync() { | 277 void createSync({bool recursive: false}) { |
| 278 if (recursive) { |
| 279 parent.createSync(recursive: true); |
| 280 } |
| 275 var result = _create(path); | 281 var result = _create(path); |
| 276 throwIfError(result, "Cannot create file", path); | 282 throwIfError(result, "Cannot create file", path); |
| 277 } | 283 } |
| 278 | 284 |
| 279 Future<File> _delete({bool recursive: false}) { | 285 Future<File> _delete({bool recursive: false}) { |
| 280 if (recursive) { | 286 if (recursive) { |
| 281 return new Directory(path).delete(recursive: true).then((_) => this); | 287 return new Directory(path).delete(recursive: true).then((_) => this); |
| 282 } | 288 } |
| 283 return _IOService.dispatch(_FILE_DELETE, [path]).then((response) { | 289 return _IOService.dispatch(_FILE_DELETE, [path]).then((response) { |
| 284 if (_isErrorResponse(response)) { | 290 if (_isErrorResponse(response)) { |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 | 879 |
| 874 void _checkAvailable() { | 880 void _checkAvailable() { |
| 875 if (_asyncDispatched) { | 881 if (_asyncDispatched) { |
| 876 throw new FileSystemException("An async operation is currently pending", p
ath); | 882 throw new FileSystemException("An async operation is currently pending", p
ath); |
| 877 } | 883 } |
| 878 if (closed) { | 884 if (closed) { |
| 879 throw new FileSystemException("File closed", path); | 885 throw new FileSystemException("File closed", path); |
| 880 } | 886 } |
| 881 } | 887 } |
| 882 } | 888 } |
| OLD | NEW |