Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

WAD MKLINK File symlinks are absolute

Oct
92
0
MKLINK is creating absolute file symlinks when /a is not used.

Code:
56.6G C:\tmp1> touch /c foo
2011-12-30 16:21:50.287  C:\tmp1\foo

56.6G C:\tmp1> mklink bar foo
Symbolic link created for bar <<===>> C:\tmp1\foo

56.6G C:\tmp1> dir

 Volume in drive C is OS             Serial number is 32f0:9b4c
 Directory of  C:\tmp1\*

2011-12-30  16:21         <DIR>    .
2011-12-30  16:21         <DIR>    ..
2011-12-30  16:21     <SYMLINK>    bar [C:\tmp1\foo]
2011-12-30  16:21               0  foo
                 0 bytes in 2 files and 2 dirs
    60,780,445,696 bytes free
 
Yes. If you, for example, move tmp1 to D:, it would be nice if bar was still pointing at foo, rather than at a nonexistent file in a nonexistent directory. This is also a cmd compatibility issue:
Code:
C:\Users\johnb\tmp0> echo.>foo
 
C:\tmp0> mklink bar foo
symbolic link created for bar <<===>> foo
 
C:\tmp0> dir
Volume in drive C is OS
Volume Serial Number is 32F0-9B4C
 
Directory of C:\tmp0
 
2011-12-30  19:25    <DIR>          .
2011-12-30  19:25    <DIR>          ..
2011-12-30  19:25    <SYMLINK>      bar [foo]
2011-12-30  19:24                2 foo
              2 File(s)              2 bytes
              2 Dir(s)  59,592,462,336 bytes free
I can use Hermann Schinagl’s ln.exe to do it if you really object to adding it, but then I have to think about it because that command has the link and target in opposite order.
 
Are you sure that Windows will actually move a relative link to another disk?
Don't know about another disk, but CMD does move a relative file symlink (with a non-existent target) to another folder.
Code:
[C:\test]cmd
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2010 Microsoft Corporation. All rights reserved.
 
C:\test>mkdir dA
 
C:\test>mklink dA\linkB B
symbolic link created for dA\linkB <<===>> B
 
C:\test>dir /S
 
Directory of C:\test
 
01/01/2012 09:51 AM <DIR> dA
0 File(s) 0 bytes
 
Directory of C:\test\dA
 
01/01/2012 09:51 AM <SYMLINK> linkB [B]
1 File(s) 0 bytes
 
Total Files Listed:
1 File(s) 0 bytes
5 Dir(s) 71,142,207,488 bytes free
 
C:\test>move dA dB
1 dir(s) moved.
 
C:\test>dir /S
 
Directory of C:\test
 
01/01/2012 09:51 AM <DIR> dB
0 File(s) 0 bytes
 
Directory of C:\test\dB
 
01/01/2012 09:51 AM <SYMLINK> linkB [B]
1 File(s) 0 bytes
 
Total Files Listed:
1 File(s) 0 bytes
5 Dir(s) 71,142,207,488 bytes free
 
C:\test>echo text >dB\B
 
C:\test>type dB\linkB
text
 
Windows will not move a directory containing relative symlinks without help (they are converted to files). However, consider where the symlink is on an NTFS-formatted external drive that is E: on one machine but D: on another.
 
Windows will not move a directory containing relative symlinks without help (they are converted to files). However, consider where the symlink is on an NTFS-formatted external drive that is E: on one machine but D: on another.
Or it can be C: (internal) on its own system, but mapped to another letter on another system (Z: is the first choice). Only relative links are mappable. It is one of the reasons I am considering upgrading to Win7.
 

Similar threads

Back
Top