Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1790)

Unified Diff: sdk/lib/io/file_impl.dart

Issue 52363002: dart:io | Add 'recursive' flag to File.create and Link.create. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Indentation. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/file.dart ('k') | sdk/lib/io/link.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « sdk/lib/io/file.dart ('k') | sdk/lib/io/link.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698