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

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

Issue 23889008: Move delete/deleteSync up to FileSystemEntity, with a shared documentation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Style fixes. Created 7 years, 3 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_system_entity.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/link.dart
diff --git a/sdk/lib/io/link.dart b/sdk/lib/io/link.dart
index d774fa266c48e4922f132391520b609d37c51b35..3df3fc9f1d5692534f1556aa1b69dae5303b7a8c 100644
--- a/sdk/lib/io/link.dart
+++ b/sdk/lib/io/link.dart
@@ -65,23 +65,6 @@ abstract class Link implements FileSystemEntity {
Future<Link> update(String target);
/**
- * Deletes the link. Returns a [:Future<Link>:] that completes with
- * the link when it has been deleted. This does not delete, or otherwise
- * affect, the target of the link. It also works on broken links, but if
- * the link does not exist or is not actually a link, it completes the
- * future with a LinkException.
- */
- Future<Link> delete();
-
- /**
- * Synchronously deletes the link. This does not delete, or otherwise
- * affect, the target of the link. It also works on broken links, but if
- * the link does not exist or is not actually a link, it throws a
- * LinkException.
- */
- void deleteSync();
-
- /**
* Renames this link. Returns a `Future<Link>` that completes
* with a [Link] instance for the renamed link.
*
@@ -213,7 +196,10 @@ class _Link extends FileSystemEntity implements Link {
return delete().then((_) => create(target));
}
- Future<Link> delete() {
+ Future<Link> _delete({bool recursive: false}) {
+ if (recursive) {
+ return new Directory(path).delete(recursive: true).then((_) => this);
+ }
_ensureFileService();
List request = new List(2);
request[0] = _DELETE_LINK_REQUEST;
@@ -226,8 +212,11 @@ class _Link extends FileSystemEntity implements Link {
});
}
- void deleteSync() {
- var result = _File._deleteLink(path);
+ void _deleteSync({bool recursive: false}) {
+ if (recursive) {
+ return new Directory(path).deleteSync(recursive: true);
+ }
+ var result = _File._deleteLinkNative(path);
throwIfError(result, "Cannot delete link", path);
}
« no previous file with comments | « sdk/lib/io/file_system_entity.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698