Is FSGetVolumeInfo the recommended alternative to NSWorkspace with the deprecated method set by LocalVolumePaths?

I need to get a list of mounted local volumes on Mac OS X. Previously, Cocoa class NSWorkspace had a mountedLocalVolumePaths method to get an array of mount points for such volumes. Starting with Lion, this is now deprecated, without any hint in the documentation about what we should use instead.

The only other Apple API I have found that provides this information is the FSGetVolumeInfo function from CoreServices.framework. This lists the mounted volumes if you pass kFSInvalidVolumeRefNum for the volume parameter and 1..N for volumeIndex. It returns the volume name (like HFSUniStr255 ) via the outputName parameter and the mount point through the rootDirectory output parameter as FSRef , which in turn can be converted to a URL using CFURLCreateFromFSRef() .

This seems a bit confusing and unreasonably low.

There are also BSD level functions, getfsstat() and getmntinfo() that emit an array of statfs structures. The API seems more understandable than the Core Services version.

Are there any higher level replacements that I should use instead?

+4
source share
1 answer

In a much more logical place, it is much easier to replace older methods: the NSFileManager mountedVolumeURLsIncludingResourceValuesForKeys:options: method .

+8
source

Source: https://habr.com/ru/post/1415592/


All Articles