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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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({bool recursive: false}) { | 259 Future<File> create({bool recursive: false}) { |
260 return (recursive ? parent.create(recursive: true) | 260 var result = recursive ? parent.create(recursive: true) |
261 : new Future.value(null)) | 261 : new Future.value(null); |
| 262 return result |
262 .then((_) => _IOService.dispatch(_FILE_CREATE, [path])) | 263 .then((_) => _IOService.dispatch(_FILE_CREATE, [path])) |
263 .then((response) { | 264 .then((response) { |
264 if (_isErrorResponse(response)) { | 265 if (_isErrorResponse(response)) { |
265 throw _exceptionFromResponse(response, "Cannot create file", path); | 266 throw _exceptionFromResponse(response, "Cannot create file", path); |
266 } | 267 } |
267 return this; | 268 return this; |
268 }); | 269 }); |
269 } | 270 } |
270 | 271 |
271 external static _create(String path); | 272 external static _create(String path); |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 | 890 |
890 void _checkAvailable() { | 891 void _checkAvailable() { |
891 if (_asyncDispatched) { | 892 if (_asyncDispatched) { |
892 throw new FileSystemException("An async operation is currently pending", p
ath); | 893 throw new FileSystemException("An async operation is currently pending", p
ath); |
893 } | 894 } |
894 if (closed) { | 895 if (closed) { |
895 throw new FileSystemException("File closed", path); | 896 throw new FileSystemException("File closed", path); |
896 } | 897 } |
897 } | 898 } |
898 } | 899 } |
OLD | NEW |