从文件 URL 确定 AFP 共享
我编写一个应用程序将一些文件复制到某个位置。它允许用户选择始终位于 AFP 共享上的目的地。这是通过 NSOpenPanel 完成的。返回的 URL 为:file://localhost/Volumes/Oliver%20Legg's%20Backup/
。
我想要完成的是当应用程序启动时,如果未安装 AFP 共享,我希望它自动安装。最好的方法是什么?
“获取信息”命令将服务器列出为:afp://Power Mac G5._afpovertcp.local/Oliver%20Legg's%20Backup
。如何以编程方式从文件 URL 获取此 URL?我想如果我可以获得该 URL,我可以使用 FSMountServerVolumeAsync。这是最好的(最简单、最抽象的)API 吗?
I writing an application to copy some files to a certain location. It allows the user to choose the destination, which is always on an AFP share. This is done with a NSOpenPanel. The URL that gets returned is: file://localhost/Volumes/Oliver%20Legg's%20Backup/
.
What I want to accomplish is when the application is started, if the AFP share isn't mounted I want it to automatically mount it. What is the best way to do this?
The Get Info command lists the server as: afp://Power Mac G5._afpovertcp.local/Oliver%20Legg's%20Backup
. How can I programatically get this URL from a file URL? I think if I could get that URL I could mount it using FSMountServerVolumeAsync. Is that the best (easiest, most abstracted) API to use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用一些较低级别的文件管理器例程来获取此信息,常规 Cocoa 调用无法做到这一点。 URL 是使用
FSCopyURLForVolume()
获取的,但您需要获取已挂载卷的卷参考号才能使用它:FSMountServerVolumeAsync
绝对是挂载卷的正确方法远程音量。You need to use some lower-level File Manager routines to get this information, there's no way to do it with regular Cocoa calls. The URL is obtained using
FSCopyURLForVolume()
but you need to get a volume reference number for the mounted volume in order to use it:FSMountServerVolumeAsync
is definitely the correct way to mount a remote volume.