[A] Determining startup volume
[A] Determining startup volume
- Subject: [A] Determining startup volume
- From: Charles Srstka <email@hidden>
- Date: Sat, 19 Oct 2002 03:56:28 -0500
Well, the startup volume is always / so all you really need to do is
call -[NSFileManager fileSystemAttributesAtPath:] with @"/" from an
argument and look up the object at key NSFileSystemNumber of the
dictionary that it returns. Do the same thing for the file you're
looking at - if the file system numbers match, they're on that volume.
If you want something a little more comprehensive, you have to use
Carbon, since Cocoa doesn't seem to have much in the way of determining
what volume something is sitting on. Here's a little method I wrote
that gets the mount point of the volume where some file lives:
- (NSString *)mountPointOfFilesystemAtPath:(NSString *)path {
FSCatalogInfo info;
FSVolumeRefNum vRefNum;
FSRef inRef, outRef;
char cPath[256];
FSPathMakeRef([path fileSystemRepresentation],&inRef,NULL);
FSGetCatalogInfo(&inRef,kFSCatInfoVolume,&info,NULL,NULL,NULL);
vRefNum = info.volume;
FSGetVolumeInfo(vRefNum,0,NULL,kFSVolInfoNone,NULL,NULL,&outRef);
FSRefMakePath(&outRef,cPath,sizeof(cPath));
return [self stringWithFileSystemRepresentation:cPath
length:strlen(cPath)];
}
Charles
On Saturday, October 19, 2002, at 02:17 AM, Mark de Jong wrote:
>
Hi!
>
>
Is there a way to determine if a given path or URL is on the startup
>
volume? I saw the "mountedLocalVolumePaths" and
>
"mountedRemoveableMedia" messages in "NSWorkspace", however, they
>
don't seem to be exactly what I'm looking for.
>
>
The best solution would be to limit an "NSOpenPanel" to the startup
>
volume, but I'm not sure how to determine if a given path is on the
>
startup volume.
>
>
Any suggestions? I didn't see anything in NSURL, either ... but I
>
could have missed it.
>
>
Thanks in advance!
>
>
-- Mark
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.