• 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
[A] Determining startup volume
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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.

References: 
 >[Q] Determining startup volume (From: Mark de Jong <email@hidden>)

  • Prev by Date: Re: [Q] Determining startup volume
  • Next by Date: Re: (newbie)cocoa and darwin 6.0....
  • Previous by thread: Re: [Q] Determining startup volume
  • Next by thread: Obj-C/C question (basic?)
  • Index(es):
    • Date
    • Thread