Index: sdk/lib/io/file_impl.dart |
diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart |
index dd618b3a7dbf904795b3626a661652f76163cb3a..e7080d73ff14ef8242361da56f3f5f43fedc3ce7 100644 |
--- a/sdk/lib/io/file_impl.dart |
+++ b/sdk/lib/io/file_impl.dart |
@@ -256,13 +256,16 @@ class _File extends FileSystemEntity implements File { |
FileStat statSync() => FileStat.statSync(path); |
- Future<File> create() { |
- return _IOService.dispatch(_FILE_CREATE, [path]).then((response) { |
- if (_isErrorResponse(response)) { |
- throw _exceptionFromResponse(response, "Cannot create file", path); |
- } |
- return this; |
- }); |
+ Future<File> create({bool recursive: false}) { |
+ return (recursive ? parent.create(recursive: true) |
+ : new Future.value(null)) |
+ .then((_) => _IOService.dispatch(_FILE_CREATE, [path])) |
+ .then((response) { |
+ if (_isErrorResponse(response)) { |
+ throw _exceptionFromResponse(response, "Cannot create file", path); |
+ } |
+ return this; |
+ }); |
} |
external static _create(String path); |
@@ -271,7 +274,10 @@ class _File extends FileSystemEntity implements File { |
external static _linkTarget(String path); |
- void createSync() { |
+ void createSync({bool recursive: false}) { |
+ if (recursive) { |
+ parent.createSync(recursive: true); |
+ } |
var result = _create(path); |
throwIfError(result, "Cannot create file", path); |
} |