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

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

Issue 23083002: dart:io | Add Link.update, and change Link.updateSync. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | « no previous file | tests/standalone/io/link_async_test.dart » ('j') | 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 8c28eb4e9ef2bcb4f5661145a62a6d6a17f21322..8b726ed5ba34136edd7eaf95368c5f2d7eecf0d0 100644
--- a/sdk/lib/io/link.dart
+++ b/sdk/lib/io/link.dart
@@ -55,14 +55,20 @@ abstract class Link implements FileSystemEntity {
* Synchronously updates the link. Calling [updateSync] on a non-existing link
* will throw an exception.
*
- * If [linkRelative] is true, the target argument should be a relative path,
- * and the link will interpret the target as a path relative to the link's
- * directory.
+ * On the Windows platform, this will only work with directories, and the
+ * target directory must exist.
+ */
+ void updateSync(String target);
+
+ /**
+ * Updates the link. Returns a [:Future<Link>:] that completes with the
+ * link when it has been updated. Calling [update] on a non-existing link
+ * will complete its returned future with an exception.
*
* On the Windows platform, this will only work with directories, and the
* target directory must exist.
*/
- void updateSync(String target, {bool linkRelative: false });
+ Future<Link> update(String target);
/**
* Deletes the link. Returns a [:Future<Link>:] that completes with
@@ -198,12 +204,23 @@ class _Link extends FileSystemEntity implements Link {
return target;
}
- void updateSync(String target, {bool linkRelative: false }) {
- // TODO(whesse): Replace with atomic update, where supported by platform.
+ void updateSync(String target) {
+ // TODO(12414): Replace with atomic update, where supported by platform.
+ // Atomically changing a link can be done by creating the new link, with
+ // a different name, and using the rename() posix call to move it to
+ // the old name atomically.
deleteSync();
createSync(target);
}
+ Future<Link> update(String target) {
+ // TODO(12414): Replace with atomic update, where supported by platform.
+ // Atomically changing a link can be done by creating the new link, with
+ // a different name, and using the rename() posix call to move it to
+ // the old name atomically.
+ return delete().then((_) => create(target));
+ }
+
Future<Link> delete() {
_ensureFileService();
List request = new List(2);
« no previous file with comments | « no previous file | tests/standalone/io/link_async_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698