Re: How to get hard drive name
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.