• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: James Bucanek <email@hidden>
  • Date: Mon, 19 Apr 2010 08:29:47 -0700

Ken Thomases <mailto:email@hidden> wrote (Saturday, April 17, 2010 5:29 PM -0500):

On Apr 17, 2010, at 6:46 PM, James Bucanek wrote:

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.

It does, doesn't it?

Perhaps you can use -[NSWorkspace mountedLocalVolumePaths]?  You'd keep a copy
of the old value and recheck it on each mount/unmount notification.

As a friend of mine says: Great minds think alike ... or there's only one way out of the woods.


This is what I resorted to doing, essentially. I already had code to do this (for situations where NSWorkspace isn't available), but it's cumbersome, inefficient, and just ridiculous to receive a volume mount event and not be able to get a filesystem path to the mounted volume that was just mounted.

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.

Alas, no. My application is a backup program. It watches for events that can trigger certain actions. One of those events is the appearance of a volume containing a source or a destination. This allows you, for example, to schedule a backup of your USB thumb drive when you plug it it.


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.

Interesting workaround. I'll give that a try.

--
James Bucanek

_______________________________________________

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


References: 
 >Re: Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here... (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here...
  • Next by Date: Re: Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here...
  • Previous by thread: Re: Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here...
  • Next by thread: How to copy something to the pasteboard in a service call
  • Index(es):
    • Date
    • Thread