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

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

Issue 23532066: dart:io | Change creation of symbolic links with relative targets on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Drop .. and . segments from Windows link targets. 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 | « no previous file | tests/standalone/io/link_async_test.dart » ('j') | tests/standalone/io/link_async_test.dart » ('J')
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 83cd22379a1ad6f4556aec92b22ae5c741deb1a1..efe46b413a9a8ca0c86b24f6221c96e807aa624a 100644
--- a/sdk/lib/io/link.dart
+++ b/sdk/lib/io/link.dart
@@ -22,7 +22,8 @@ abstract class Link implements FileSystemEntity {
* On the Windows platform, this will only work with directories, and the
* target directory must exist. The link will be created as a Junction.
* Only absolute links will be created, and relative paths to the target
- * will be converted to absolute paths.
+ * will be converted to absolute paths by joining them with the path of the
+ * directory the link is contained in.
*
* On other platforms, the posix symlink() call is used to make a symbolic
* link containing the string [target]. If [target] is a relative path,
@@ -170,21 +171,15 @@ class _Link extends FileSystemEntity implements Link {
// Put target into the form "\??\C:\my\target\dir".
String _makeWindowsLinkTarget(String target) {
- if (target.startsWith('\\??\\')) {
- return target;
- }
- if (!(target.length > 3 && target[1] == ':' && target[2] == '\\')) {
- try {
- target = new File(target).fullPathSync();
- } on FileException catch (e) {
- throw new LinkException('Could not locate target', target, e.osError);
- }
- }
- if (target.length > 3 && target[1] == ':' && target[2] == '\\') {
- target = '\\??\\$target';
+ Uri base = new Uri.file('${Directory.current.path}\\');
+ Uri link = new Uri.file(path);
+ Uri destination = new Uri.file(target);
+ String result = base.resolveUri(link).resolveUri(destination).toFilePath();
+ if (result.length > 3 && result[1] == ':' && result[2] == '\\') {
+ return '\\??\\$result';
} else {
throw new LinkException(
- 'Target $target of Link.create on Windows cannot be converted' +
+ 'Target $result of Link.create on Windows cannot be converted' +
' to start with a drive letter. Unexpected error.');
}
return target;
« no previous file with comments | « no previous file | tests/standalone/io/link_async_test.dart » ('j') | tests/standalone/io/link_async_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698