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

How to get hard drive name


  • Subject: How to get hard drive name
  • From: Lorenzo <email@hidden>
  • Date: Tue, 20 Jan 2004 21:21:35 +0100

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.

  • Follow-Ups:
    • Re: How to get hard drive name
      • From: J Nozzi <email@hidden>
  • Prev by Date: Re: How to get hard drive name
  • Next by Date: Re: Using Perl in a Panther environment
  • Previous by thread: Re: How to get hard drive name
  • Next by thread: Re: How to get hard drive name
  • Index(es):
    • Date
    • Thread