Re: Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here...
Re: Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here...
- Subject: Re: Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here...
- From: Ken Thomases <email@hidden>
- Date: Sat, 17 Apr 2010 19:29:23 -0500
On Apr 17, 2010, at 6:46 PM, James Bucanek wrote:
> How do I get the mount point path of a freshly mounted volume in Snow Leopard?
>
> In Leopard (10.5), the NSWorkspaceDidMountNotification included an NSDevicePath value. It contained the path to the mount point of the freshly mounted volume.
>
> In Snow Leopard (10.6), this property has been deprecated and has been replaced with NSWorkspaceVolumeURLKey that contains an NSURL to the new volume.
>
> Here's the problem: How do you turn the NSURL into its equivalent filesystem path?
>
> For backwards compatibility, the notification still includes an NSDevicePath value, but that value is wrong for AFP volumes. For example, in 10.5 mounting the network volume "Dinah" would fire a notification containing NSDevicePath="/Volumes/Dinah". In 10.6, mounting the same volume posts a notification containing:
>
> NSWorkspaceVolumeURLKey = NSURL(afp://James Bucanek@March Hare._afpovertcp._tcp.local/Dinah)
> NSDevicePath = "/Dinah"
Does seem like a bug.
Perhaps you can use -[NSWorkspace mountedLocalVolumePaths]? You'd keep a copy of the old value and recheck it on each mount/unmount notification.
By the way, are you mounting this volume programmatically using FSMountServerVolumeSync/Async? If so, then you get a volume reference number back, and you can use FSGetVolumeInfo to get its root directory as an FSRef, and from there a path or URL.
In fact, it may be possible to use FSMountServerVolumeSync with the afp: URL you're getting from NSWorkspace. You'd effectively be asking to remount the volume that was just mounted. Hopefully, the OS will immediately return success without doing any actual new mounting, and that would be a way to get the volume reference number. On the other hand, it's just as likely to return some sort of "volume already mounted" error.
Good luck,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden