标签:
杂谈 |
目录符号链接和目录联接(看原文即目录的硬链接)的区别在于:
目录联接在创建时会自动引用目标目录的绝对路径,而符号链接允许相对路径的引用。
如分别用 mklink /D dira tdir 和 mklink /J dirb tdir 创建 dira、dirb 对 tdir 的符号链接和目录联接,之后将 dira、dirb 移动到其它目录下,则访问 dira 时会提示“位置不可用”,访问 dirb 时仍然正常指向 tdir;
而分别用 mklink /D dira c:\demo\tdir 和 mklink /J dirb c:\demo\tdir 创建 c:\demo\tdir 的符号链接和目录联接,再将这两个目录链接移动到其它目录下,则 dira 和 dirb 均可正常指向 c:\demo\tdir;
由此可见当创建目录链接时对目标目录使用绝对路径,D 和 J 两个参数实现的目录链接效果是一样的;
英文原文:
MKLINK [[/D] | [/H] | [/J]] Link Target
/D Creates a directory symbolic link. Default is a file symbolic link. /H Creates a hard link instead of a symbolic link. /J Creates a Directory Junction.
/D creates a symbolic link, or a soft link.This essentially acts like a shortcut to a folder in prior versions of Windows, except you don’t have to use an actual shortcut.
/H creates a hard link, which points directly to the file.This option can’t be used for folders directly for some reason, you’ll have to use the next option.
/J creates a “Directory Junction”A Directory Junction is actually just a hard link to a directory. This is a feature that existed prior to Vista as well. If you are trying to symlink to a directory using a hard link, then you should use this option.
Understanding Hard vs Soft Links================================Hard Link
A hard link directly points to the file, and acts to the operating system as if it is the file itself. You’ll want to use this option the majority of the time if you are trying to fake an application’s directory.
Soft Link
A soft link is essentially a shortcut to a file or folder – if you are using Windows explorer, you’ll be redirected to the directory if you double-click on a shortcut, it won’t pretend its part of the filesystem. You can still directly reference or open a file with the symlinked path, and it mostly works.
XX