Re: How to get hard drive name
Re: How to get hard drive name
- Subject: Re: How to get hard drive name
- From: J Nozzi <email@hidden>
- Date: Tue, 20 Jan 2004 15:54:06 -0500
I'd responded with the expandtilde method from the NSUserHome (names
not exact, I know - I'm in a hurry. ;-) ) but he made a valid point
that the mount point is still "/Users/..." and not /Drive/Users/... nor
/Volumes/Drive/Users ...
His question is a bit more complicated and I admit I'm stumped!
- J
On Jan 20, 2004, at 3:21 PM, Lorenzo wrote:
Hi,
given a file "theFile"
NSString *theFile = @"/Volumes/MyDisk/MyFolder/MyFile";
NSString *diskName;
NSFileManager *manager = [NSFileManager defaultManager];
you can get the volume name this way:
// this will give you an array of path components you can use
// to display the path to the user in the MacOS 9 style.
pathDisplayArray = [manager componentsToDisplayForPath:theFile];
// the first item of the array contains the disk name @"MyDisk"
// so take it from the array with the index = 0;
if(pathDisplayArray && [pathDisplayArray count] > 0){
diskName = [pathDisplayArray objectAtIndex:0];
}
// if theFile is on your boot disk like this
theFile = @"/MyBootDisk/MyFolder/MyFile";
// you will get diskName = @"MyBootDisk";
Best Regards
--
Lorenzo
email: email@hidden
Message: 14
To: email@hidden
From: "Ian G. Gillespie" <email@hidden>
Subject: How to get hard drive name
Date: Tue, 20 Jan 2004 11:30:21 -0800
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.