Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here...
Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here...
- Subject: Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here...
- From: James Bucanek <email@hidden>
- Date: Sat, 17 Apr 2010 16:46:36 -0700
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"
The path "/Dinah" is (obviously) invalid.
Here's what I've tried:
-[NSURL path]: Doesn't work (returns "/Dinah")
-[NSURL filePathURL]: Doesn't work (returns nil)
-[NSURL resourceValuesForKeys:error:] and -[NSURL
getResourceValue:forKey:error:]: I can't find any keys that
return anything useful. Specifically, NSURLVolumeURLKey doesn't
return anything.
So that's what has me stumped at the moment. This can't be done,
I'm missing something blindly obvious, or it's a bug--possibly
some combination.
_______________________________________________
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