从窗口访问cygwin符号链接

时间:2021-04-13 15:52:56

I am quite new to cygwin. I created a symlink as follows

我对赛格温很陌生。我创建了一个符号链接如下。

$ ln -s /var/www /cygdrive/d/foo

and when I check the D drive via windows, I see a system file called foo. Is there a way to make foo act as a folder for Windows instead of a system file?

当我通过windows检查D驱动器时,我看到一个名为foo的系统文件。有没有办法让foo充当Windows的文件夹而不是系统文件?

4 个解决方案

#1


8  

Not that I know of. Cygwin doesn't update the OS to have symlinks, rather, it allows you to 'fake' symlinks from within the Cygwin shell. You can set up the shell to use Windows LNK files, which may do what you want, but ...

我不知道。Cygwin不会更新操作系统的符号链接,相反,它允许你从Cygwin shell中“伪”符号链接。您可以设置shell来使用Windows LNK文件,它可以做您想做的事情,但是……

From the Cygwin Documentation:

从Cygwin文档:

Creating shortcuts with cygutils

用cygutils创建快捷方式

Another problem area is between Unix-style links, which link one file to another, and Microsoft .lnk files, which provide a shortcut to a file. They seem similar at first glance but, in reality, are fairly different. By default, Cygwin does not create symlinks as .lnk files, but there's an option to do that, see the section called “The CYGWIN environment variable”. These symlink .lnk files are compatible with Windows-created .lnk files, but they are still different. They do not include much of the information that is available in a standard Microsoft shortcut, such as the working directory, an icon, etc. The cygutils package includes a mkshortcut utility for creating standard native Microsoft .lnk files.

另一个问题是unix样式的链接(链接一个文件到另一个文件)和Microsoft .lnk文件(提供文件的快捷方式)之间的问题。乍一看,它们似乎很相似,但实际上却完全不同。默认情况下,Cygwin不会创建符号链接。lnk文件,但是有一个选项可以这样做,参见“Cygwin环境变量”这一节。这些符号链接。lnk文件与windows创建的.lnk文件兼容,但它们仍然不同。它们不包含在标准的Microsoft快捷方式中可用的大部分信息,例如工作目录、图标等。cygutils包包含用于创建标准的Microsoft .lnk文件的mk快捷方式实用程序。

But here's the problem. If Cygwin handled these native shortcuts like any other symlink, you could not archive Microsoft .lnk files into tar archives and keep all the information in them. After unpacking, these shortcuts would have lost all the extra information and would be no different than standard Cygwin symlinks. Therefore these two types of links are treated differently. Unfortunately, this means that the usual Unix way of creating and using symlinks does not work with native Windows shortcuts.

但是问题就在这里。如果Cygwin像处理其他符号链接一样处理这些本地快捷方式,您就不能将Microsoft .lnk文件归档到tar存档中,并将所有信息保存在其中。在打开包装之后,这些快捷方式将丢失所有额外的信息,并且与标准的Cygwin symlinks没有什么不同。因此,这两种类型的链接被区别对待。不幸的是,这意味着通常使用Unix创建和使用符号链接的方式不能使用本机Windows快捷方式。

#2


11  

Two years later, but I have the answer

两年后,我有了答案

CYGWIN=winsymlinks:native
ln -s SOURCE TARGET

The CYGWIN environment variable

CYGWIN环境变量

#3


10  

Windows won't be able to read Cygwin-created symlinks, but you can create Windows symlinks using Windows commands, and Cygwin will treat those as symlinks.

Windows无法读取Cygwin创建的符号链接,但可以使用Windows命令创建Windows符号链接,Cygwin将这些符号链接视为符号链接。

On Vista and 7, this can be done with 'mklink'. This is a cmd.exe builtin rather than a standalone utility, so if you want to invoke it from a bash shell you have to do 'cmd /c mklink', and of course it will only understand Windows paths.

在Vista和7上,这可以通过“mklink”实现。这是一个cmd。exe内建,而不是独立的实用程序,所以如果您想从bash shell调用它,您必须执行“cmd /c mklink”,当然,它只理解Windows路径。

For XP, the 'Windows Resource Kit Tools' contain a utility called linkd that can be used to create directory links.

对于XP,“Windows资源工具包工具”包含一个名为linkd的实用工具,可以用来创建目录链接。

#4


3  

One alternative way to call mklink (/d creates directory link) without function:

调用mklink (/d创建目录链接)的一种替代方法是:

link_name="/cygdrive/c/TestLink"
target_dir="/cygwin/c/Windows"
cmd /c mklink /d "`cygpath -w \"$link_name\"`" "`cygpath -w \"$target_dir\"`"

This example uses backticks (`command`) for command substitution.

这个示例使用回勾(' command ')进行命令替换。

#1


8  

Not that I know of. Cygwin doesn't update the OS to have symlinks, rather, it allows you to 'fake' symlinks from within the Cygwin shell. You can set up the shell to use Windows LNK files, which may do what you want, but ...

我不知道。Cygwin不会更新操作系统的符号链接,相反,它允许你从Cygwin shell中“伪”符号链接。您可以设置shell来使用Windows LNK文件,它可以做您想做的事情,但是……

From the Cygwin Documentation:

从Cygwin文档:

Creating shortcuts with cygutils

用cygutils创建快捷方式

Another problem area is between Unix-style links, which link one file to another, and Microsoft .lnk files, which provide a shortcut to a file. They seem similar at first glance but, in reality, are fairly different. By default, Cygwin does not create symlinks as .lnk files, but there's an option to do that, see the section called “The CYGWIN environment variable”. These symlink .lnk files are compatible with Windows-created .lnk files, but they are still different. They do not include much of the information that is available in a standard Microsoft shortcut, such as the working directory, an icon, etc. The cygutils package includes a mkshortcut utility for creating standard native Microsoft .lnk files.

另一个问题是unix样式的链接(链接一个文件到另一个文件)和Microsoft .lnk文件(提供文件的快捷方式)之间的问题。乍一看,它们似乎很相似,但实际上却完全不同。默认情况下,Cygwin不会创建符号链接。lnk文件,但是有一个选项可以这样做,参见“Cygwin环境变量”这一节。这些符号链接。lnk文件与windows创建的.lnk文件兼容,但它们仍然不同。它们不包含在标准的Microsoft快捷方式中可用的大部分信息,例如工作目录、图标等。cygutils包包含用于创建标准的Microsoft .lnk文件的mk快捷方式实用程序。

But here's the problem. If Cygwin handled these native shortcuts like any other symlink, you could not archive Microsoft .lnk files into tar archives and keep all the information in them. After unpacking, these shortcuts would have lost all the extra information and would be no different than standard Cygwin symlinks. Therefore these two types of links are treated differently. Unfortunately, this means that the usual Unix way of creating and using symlinks does not work with native Windows shortcuts.

但是问题就在这里。如果Cygwin像处理其他符号链接一样处理这些本地快捷方式,您就不能将Microsoft .lnk文件归档到tar存档中,并将所有信息保存在其中。在打开包装之后,这些快捷方式将丢失所有额外的信息,并且与标准的Cygwin symlinks没有什么不同。因此,这两种类型的链接被区别对待。不幸的是,这意味着通常使用Unix创建和使用符号链接的方式不能使用本机Windows快捷方式。

#2


11  

Two years later, but I have the answer

两年后,我有了答案

CYGWIN=winsymlinks:native
ln -s SOURCE TARGET

The CYGWIN environment variable

CYGWIN环境变量

#3


10  

Windows won't be able to read Cygwin-created symlinks, but you can create Windows symlinks using Windows commands, and Cygwin will treat those as symlinks.

Windows无法读取Cygwin创建的符号链接,但可以使用Windows命令创建Windows符号链接,Cygwin将这些符号链接视为符号链接。

On Vista and 7, this can be done with 'mklink'. This is a cmd.exe builtin rather than a standalone utility, so if you want to invoke it from a bash shell you have to do 'cmd /c mklink', and of course it will only understand Windows paths.

在Vista和7上,这可以通过“mklink”实现。这是一个cmd。exe内建,而不是独立的实用程序,所以如果您想从bash shell调用它,您必须执行“cmd /c mklink”,当然,它只理解Windows路径。

For XP, the 'Windows Resource Kit Tools' contain a utility called linkd that can be used to create directory links.

对于XP,“Windows资源工具包工具”包含一个名为linkd的实用工具,可以用来创建目录链接。

#4


3  

One alternative way to call mklink (/d creates directory link) without function:

调用mklink (/d创建目录链接)的一种替代方法是:

link_name="/cygdrive/c/TestLink"
target_dir="/cygwin/c/Windows"
cmd /c mklink /d "`cygpath -w \"$link_name\"`" "`cygpath -w \"$target_dir\"`"

This example uses backticks (`command`) for command substitution.

这个示例使用回勾(' command ')进行命令替换。