how to get connected drive list of MAC?

Discussion in 'Mac Programming' started by newformac, Aug 16, 2011.

  1. newformac macrumors regular

    Joined:
    May 24, 2011
    #1
    how to i get how nay drive are connected with mac machine.

    get this list with drive details like name,serial num or volume etc. and so on.

    thank.

    any help and suggestion on this will be appreciated.
     
  2. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #2
    "About this Mac", "More Info".
     
  3. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #3
    Code:
    diskutil list -plist
    from the command line may give you a programmatic interface.

    for other options like info that could be useful.

    B
     
  4. newformac thread starter macrumors regular

    Joined:
    May 24, 2011
  5. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #5
    Look into DiskArbitration framework, which is a higher level wrapper for IOKit. Both are C-based APIs though, there is no native Objective-C one.
     
  6. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #6
    I don't know why some folks resist the notion that you can also programmatically simply use NSTask or NSPipe to call a helper function that will do the job for you...

    B
     
  7. larkost macrumors 6502a

    Joined:
    Oct 13, 2007
    #7
    Because then you are dependent on the absolute formatting of the text output. The moment something changes (which it does on a regular basis), then you are screwed. This sort of thing is fine for scripts that you make for yourself, and can maintain yourself, but it is not fine for things that you share with others (free or not).

    And there are solid APIs on MacOS X for this. When programming you should use them.
     
  8. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #8

    Not in this case. If you actually took the time to look at what was suggested you'd see this from the man page:

    So the format is designed specifically for this sort of usage.
     

Share This Page