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

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

Issue 13654002: Change how File/Directory/Link .delete works. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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
Index: sdk/lib/io/link.dart
diff --git a/sdk/lib/io/link.dart b/sdk/lib/io/link.dart
index fee4f97fc6271aef7a1e7862dc1eab7ce2af1d10..ad3e6603969ad2676d365a82e7338cb6a67e3894 100644
--- a/sdk/lib/io/link.dart
+++ b/sdk/lib/io/link.dart
@@ -164,11 +164,21 @@ class _Link extends FileSystemEntity implements Link {
}
Future<Link> delete() {
- return new File(path).delete().then((_) => this);
+ _ensureFileService();
+ List request = new List(2);
+ request[0] = _LINK_DELETE_REQUEST;
+ request[1] = path;
+ return _fileService.call(request).then((response) {
+ if (_isErrorResponse(response)) {
+ throw _exceptionFromResponse(response, "Cannot delete file '$path'");
+ }
+ return this;
+ });
}
void deleteSync() {
- new File(path).deleteSync();
+ var result = _File._deleteLink(path);
+ throwIfError(result, "Cannot delete file '$path'");
}
Future<String> target() {
@@ -183,6 +193,12 @@ class _Link extends FileSystemEntity implements Link {
}
return result;
}
+
+ static throwIfError(Object result, String msg) {
+ if (result is OSError) {
+ throw new FileIOException(msg, result);
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698