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

Unified Diff: utils/pub/io.dart

Issue 10825158: Get symlinks working in pub on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/io.dart
diff --git a/utils/pub/io.dart b/utils/pub/io.dart
index b08e65ae1a85cc1b41ebf6827862fa31075ae7f5..06ac7df1c972e7817893abd288010c0cdc0f866f 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -255,11 +255,23 @@ Future<Directory> cleanDir(dir) {
* completes to the symlink file (i.e. [to]).
*/
Future<File> createSymlink(from, to) {
- // TODO(rnystrom): What should this do on Windows?
from = _getPath(from);
to = _getPath(to);
- return runProcess('ln', ['-s', from, to]).transform((result) {
+ var command = 'ln';
+ var args = ['-s', from, to];
+
+ if (Platform.operatingSystem == 'windows') {
+ // Call mklink on Windows to create an NTFS junction point. Only works on
+ // Vista or later. (Junction points are available earlier, but the "mklink"
+ // command is not.) I'm using a junction point (/j) here instead of a soft
+ // link (/d) because the latter requires some privilege shenanigans that
+ // I'm not sure how to specify from the command line.
+ command = 'cmd';
+ args = ['/c', 'mklink', '/j', to, from];
+ }
+
+ return runProcess(command, args).transform((result) {
// TODO(rnystrom): Check exit code and output?
return new File(to);
});
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698