| Index: runtime/bin/directory_impl.dart
|
| diff --git a/runtime/bin/directory_impl.dart b/runtime/bin/directory_impl.dart
|
| index 598a5a4e14e5c58dfbba03bd88cb4e9146b58992..f455d7477f7beb72cedfd0842b459fe2d9396659 100644
|
| --- a/runtime/bin/directory_impl.dart
|
| +++ b/runtime/bin/directory_impl.dart
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| @@ -94,13 +94,14 @@ class _DirCreateTempOperation extends _DirectoryOperation {
|
|
|
|
|
| class _DirDeleteOperation extends _DirectoryOperation {
|
| - _DirDeleteOperation(String this._path);
|
| + _DirDeleteOperation(String this._path, bool this._recursive);
|
|
|
| void execute(ReceivePort port) {
|
| - _replyPort.send(_Directory._delete(_path), port.toSendPort());
|
| + _replyPort.send(_Directory._delete(_path, _recursive), port.toSendPort());
|
| }
|
|
|
| String _path;
|
| + bool _recursive;
|
| }
|
|
|
|
|
| @@ -165,12 +166,13 @@ class _Directory implements Directory {
|
| _OSStatus status) native "Directory_CreateTemp";
|
| static int _exists(String path) native "Directory_Exists";
|
| static bool _create(String path) native "Directory_Create";
|
| - static bool _delete(String path) native "Directory_Delete";
|
| + static bool _delete(String path, bool recursive) native "Directory_Delete";
|
|
|
| void exists() {
|
| - var handler = (_existsHandler != null) ? _existsHandler : (result) => null;
|
| var operation = new _DirExistsOperation(_path);
|
| _scheduler.enqueue(operation, (result, ignored) {
|
| + var handler =
|
| + (_existsHandler != null) ? _existsHandler : (result) => null;
|
| if (result < 0) {
|
| if (_errorHandler != null) {
|
| _errorHandler("Diretory exists test failed: $_path");
|
| @@ -190,9 +192,9 @@ class _Directory implements Directory {
|
| }
|
|
|
| void create() {
|
| - var handler = (_createHandler != null) ? _createHandler : () => null;
|
| var operation = new _DirCreateOperation(_path);
|
| _scheduler.enqueue(operation, (result, ignored) {
|
| + var handler = (_createHandler != null) ? _createHandler : () => null;
|
| if (result) {
|
| handler();
|
| } else if (_errorHandler != null) {
|
| @@ -208,10 +210,10 @@ class _Directory implements Directory {
|
| }
|
|
|
| void createTemp() {
|
| - var handler =
|
| - (_createTempHandler != null) ? _createTempHandler : () => null;
|
| var operation = new _DirCreateTempOperation(_path);
|
| _scheduler.enqueue(operation, (result, ignored) {
|
| + var handler =
|
| + (_createTempHandler != null) ? _createTempHandler : () => null;
|
| if (result is !_OSStatus) {
|
| _path = result;
|
| handler();
|
| @@ -235,20 +237,24 @@ class _Directory implements Directory {
|
| }
|
| }
|
|
|
| - void delete() {
|
| - var handler = (_deleteHandler != null) ? _deleteHandler : () => null;
|
| - var operation = new _DirDeleteOperation(_path);
|
| + void delete([bool recursive = false]) {
|
| + var operation = new _DirDeleteOperation(_path, recursive);
|
| _scheduler.enqueue(operation, (result, ignored) {
|
| + var handler = (_deleteHandler != null) ? _deleteHandler : () => null;
|
| if (result) {
|
| handler();
|
| } else if (_errorHandler != null) {
|
| - _errorHandler("Directory deletion failed: $_path");
|
| + if (recursive) {
|
| + _errorHandler("Recursive directory deletion failed: $_path");
|
| + } else {
|
| + _errorHandler("Non-recursive directory deletion failed: $_path");
|
| + }
|
| }
|
| });
|
| }
|
|
|
| - void deleteSync() {
|
| - if (!_delete(_path)) {
|
| + void deleteSync([bool recursive = false]) {
|
| + if (!_delete(_path, recursive)) {
|
| throw new DirectoryException("Directory deletion failed: $_path");
|
| }
|
| }
|
|
|