• 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: looking for sample code to read UUID from a disk volume.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: looking for sample code to read UUID from a disk volume.


  • Subject: Re: looking for sample code to read UUID from a disk volume.
  • From: James Bucanek <email@hidden>
  • Date: Wed, 9 Apr 2008 12:20:44 -0700

Kenny Leung <mailto:email@hidden> wrote (Wednesday, April 9, 2008 11:49 AM -0700):
I am looking for sample code to obtain the UUID. Any pointers are greatly appreciated!

If you're only running on Leopard, one simply way is to use the new FSEventsCopyUUIDForDevice() function. I suspect that this was introduced primarily to make it easier to use file system events, but it's also a convenient method for just obtaining a volume's UUID.


// Get the device identifier for the given path
struct statfs stat;
NSString* path = [[pathToAnyItemOnVolume stringByExpandingTildeInPath] stringByStandardizingPath];
if (statfs([[NSFileManager defaultManager] fileSystemRepresentationWithPath:path],&stat)!=0)
{
NSLog(@"statfs error %d",errno);
return;
}
dev_t device = stat.f_fsid.val[0];


    CFUUIDRef uuid = FSEventsCopyUUIDForDevice(device);
    CFStringRef uuidStr = CFUUIDCreateString(uuid);
    CFRelease(uuid);        // CF copy rule

    return ((NSString*)uuidStr);

--
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: 
 >looking for sample code to read UUID from a disk volume. (From: Kenny Leung <email@hidden>)

  • Prev by Date: Re: looking for sample code to read UUID from a disk volume.
  • Next by Date: Re: Tips to deploy applications to multiple Mac OS X versions
  • Previous by thread: Re: looking for sample code to read UUID from a disk volume.
  • Next by thread: *** -[NSConcreteFileHandle availableData]: Invalid argument
  • Index(es):
    • Date
    • Thread