Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find mounted storage devices in OSX?

How can I find the mounted storage devices and get information about them ? Basically I want a similar behavior like in the finder sidebar.

***Update: Generally I need to show the devices names and types

At the moment I am looking into the /Volumes/ directory and just list whats in there, but that leaves me with 2 problems:

  1. I have unwanted items, e.g. MobileBackups
  2. I can not identify the device

The second problem is really bugging me. If I could identify the item, I could also sort out the unwanted items, but I do not even know if it is a mounted DMG, USB device, or network device.

I already looked at a few examples, but not getting anywhere. The apple sample FSMegaInfo, already gives a bit information, but does I am not sure if I am able to identify the type of device. I am also not sure how I get the required information to scan the device. Also DADiskCopyDescription does not seem to give me the required information.

I also use the NSWorkspace notification to get information about new mounted or unmounted devices, but the notification event does not really provide any information.

Is there no easy way ?

Thanks for the help.

Seb

like image 842
elementsense Avatar asked Apr 09 '13 14:04

elementsense


2 Answers

Ask an NSFileManager object what volumes are mounted.

like image 197
Peter Hosey Avatar answered Nov 03 '22 16:11

Peter Hosey


Use this: -[NSFileManager mountedVolumeURLsIncludingResourceValuesForKeys:options:].

like image 42
Caleb Avatar answered Nov 03 '22 15:11

Caleb