Re: Network volume
Re: Network volume
- Subject: Re: Network volume
- From: Ken Thomases <email@hidden>
- Date: Tue, 23 Dec 2008 22:00:22 -0600
On Dec 23, 2008, at 7:29 PM, Jerry Krinock wrote:
On 2008 Dec, 23, at 14:02, Nor wrote:
But I don't know which volumes were networks'.
Well, I'd imagine you'd have the same problem if the USB cable on a
local drive was yanked out. So, you need to identify anything not
on the startup volume. I know this is a stupid answer, but
actually, I've done this in an application, and it works. Assuming
you've got the path of a filesystem item,
NSArray* comps = [path pathComponents] ;
if ([[pathComps objectAtIndex:1 isEqualToString:@"Volumes"])
{
// It's a network or non-startup drive!!
Or at least, someone who knows a better way might be irked enough to
give a Holiday Reply :)
Damn it, you got me! I'm a sucker for correcting misinformation. ;)
In case you hadn't noticed, your boot volume is also available in /
Volumes.
What you're looking for is available via the FSGetVolumeParms API.
See the discussion of the bIsOnExternalBus and bIsOnInternalBus bits
of the vMExtendedAttributes field of the GetVolParmsInfoBuffer struct
in this header:
/System/Library/Frameworks/CoreServices.framework/Frameworks/
CarbonCore.framework/Headers/Files.h
You can get similar information from Disk Arbitration, if you're
already using that. The description dictionary may contain keys
DADeviceInternal or DAVolumeNetwork, which if present have CFBoolean
values.
For AFP-mounted network volumes, you can obtain address information
using FSGetVolumeMountInfo.
See the FSMegaInfo sample code to see how these APIs can be used. Its
source also includes some additional notes that you won't find in the
documentation.
http://developer.apple.com/samplecode/FSMegaInfo/
All of that said, I doubt very much that any of this will help the
original poster. If the OS is capable of informing you that a network
connection has been cut (via the network reachability API, for
example) then it would also notice that the network volume had become
unavailable and would deliver the unmount notification. By monitoring
the unmount notification (or the Disk Arbitration "disappeared"
event), you're going to get the system's best effort for informing you
of the volume becoming unavailable. I doubt you'll be able to do
better.
If that's not good enough, then you have a design problem with your
application. For example, if your application is performing
synchronous I/O and blocking when a network volume is unresponsive,
then you have to change to using asynchronous I/O. Any attempt to
detect the problem is 1) going to fail, and 2) going to leave you with
other usability problems -- for example, when a connection to a
network volume is not truly down but is running very slowly.
Cheers,
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