• 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: How to get hard drive name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get hard drive name


  • Subject: Re: How to get hard drive name
  • From: p3consulting <email@hidden>
  • Date: Wed, 21 Jan 2004 16:16:41 +0100

@interface NSFileManager(DeviceInfo)

- (BOOL)device:(NSString **)outDevice mountPoint:(NSString
**)outMountPoint fileSystem:(NSString **)outFSName
forFilePath:(NSString *)inFilePath;

@end

@implementation NSFileManager(DeviceInfo)

- (BOOL)device:(NSString **)outDevice mountPoint:(NSString
**)outMountPoint fileSystem:(NSString **)outFSName
forFilePath:(NSString *)inFilePath
{
struct statfs buf ;
int error ;

error = statfs([[inFilePath stringByStandardizingPath] cString],&buf);
if (error == 0) {
if (outMountPoint)
*outMountPoint = [NSString stringWithCString:buf.f_mntonname] ;
if (outDevice)
*outDevice = [NSString stringWithCString:buf.f_mntfromname] ;
if (outFSName)
*outFSName = [NSString stringWithCString:buf.f_fstypename] ;

return YES ;
}
return NO ;

}

@end

To use:

[[NSFileManager defaultManager] device:&outDevice
mountPoint:&outMountPoint fileSystem:&outFSName
forFilePath:NSHomeDirectory()];

Example of results:

outDevice /dev/disk1s15
outMountPoint /
outFSName hfs

Pascal Pochet
P3 Consulting


On 20 janv. 2004, at 20:30, Ian G. Gillespie wrote:

> Greetings,
>
> Does anyone know how I can get the name of a user's hard drive, or the
> hard drive partition on which their user account resides?
>
> ~Ian
> _______________________________________________
> 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: 
 >How to get hard drive name (From: "Ian G. Gillespie" <email@hidden>)

  • Prev by Date: Re: Q: how do you generate get/set methods?
  • Next by Date: CMKY <-> RGBA transforms?
  • Previous by thread: Re: How to get hard drive name
  • Next by thread: How to get hard drive name
  • Index(es):
    • Date
    • Thread