为什么我可以在NSOpenPanel中选择别名而不选择符号链接? [英] Why can I select aliases but not symbolic links in NSOpenPanel?

查看:52
本文介绍了为什么我可以在NSOpenPanel中选择别名而不选择符号链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个 NSOpenPanel 可以选择任何类型的文件,所以我这样做

I want to create an NSOpenPanel that can select any kind of file, so I do this

NSOpenPanel*    panel = [NSOpenPanel openPanel];

if([panel runModalForTypes:nil] == NSOKButton) {
    // process files here
}

这使我可以选择除 符号链接之外的所有文件.
它们根本无法选择,并且明显是 setResolvesAliases
什么都不做.

which lets me select all files except symbolic links.
They're simply not selectable and the obvious setResolvesAliases
does nothing.

有什么作用?

更新1:我做了一些测试,发现这种奇怪之处
在豹(10.5.5)中存在,但在老虎(10.4.8)中不存在.

Update 1: I did some more testing and found that this strangeness
is present in Leopard (10.5.5) but not in Tiger (10.4.8).

更新2:上面的代码可以选择mac别名(永久路径
驻留在资源派生中的数据)而不是符号链接(使用ln -s创建的文件).

Update 2: The code above can select mac aliases (persistent path
data that lives in the resource fork) but not symlinks (files created with ln -s).

推荐答案

我无法重现此内容.我刚试过,它很好用.如果symlink指向目录,则在选择符号链接时它会显示目录内容;如果symlink指向文件,则也可以选择它.

I cannot reproduce this. I just tried it and it works just fine. If symlink points to a directory, it shows the directory content when I select the symlink and if the symlink points to a file, I can select it as well.

当然,如果符号链接指向目录,则只有在允许选择目录的情况下才可以选择它

Of course if the symlink points to a directory, you can only select it if choosing directories is allowed

NSOpenPanel * panel = [NSOpenPanel openPanel];
[panel setCanChooseDirectories:YES];
if ([panel runModalForTypes:nil] == NSOKButton) {
    NSLog(@"%@", [panel filenames]);
}

这篇关于为什么我可以在NSOpenPanel中选择别名而不选择符号链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆