• 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: Brian Ganninger <email@hidden>
  • Date: Tue, 20 Jan 2004 16:06:56 -0600

This techniques all seem overly complicated. Given a valid path to a volume just use:

[[NSFileManager defaultManager] displayNameAtPath:@"/path/To/Drive"];

As for targeting the home directory: NSHomeDirectory()

This simple function will work in any place you need to start with ~/ and as stated, build your path and expandTildeInPath.

HTH,
brian

On Jan 20, 2004, at 2:54 PM, J Nozzi wrote:

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

  • Follow-Ups:
    • Re: How to get hard drive name
      • From: J Nozzi <email@hidden>
References: 
 >How to get hard drive name (From: Lorenzo <email@hidden>)
 >Re: How to get hard drive name (From: J Nozzi <email@hidden>)

  • Prev by Date: modal window - enable paste, quit
  • Next by Date: Re: How to get hard drive name
  • Previous by thread: Re: How to get hard drive name
  • Next by thread: Re: How to get hard drive name
  • Index(es):
    • Date
    • Thread