1
votes

I am developing an OSX application that among other things shows mounted volumes as they appear/disappear. I do that using the disk arbitration framework. When I connect my computer to a network drive that I have configured as my time machine backup then a volume appears with the name "timemachine", i.e. the CFDictionary of the appearing device is this:

{DAVolumeMountable=true, DAVolumeNetwork=true, DAVolumeName=timemachine, DAVolumePath=file://localhost/Volumes/timemachine/, DAVolumeKind=afpfs}

I don't want this volume to appear in my application's UI. What criterion can I use to know it is really a time machine volume to exclude it? Just using the name or path seems weird. Wouldn't a drive formatted to have the name "timemachine" theoretically be mounted under the same name/path?

Any advice appreciated.

1

1 Answers

0
votes

I don't find an API that identifies Time Machine volumes. You could call out to the tmutil program with the destinationinfo verb. I also see files such as ".com.apple.timemachine.donotpresent" on my Time Machine volume, although that's relying on undocumented implementation details.

By the way, a Time Machine volume can still be used as normal by the user. At least a local one can. They can browse into it and put other files on it besides their backup. Obviously, they shouldn't put anything there that they would be sorry to lose if a drive fails.

If you only want to show the same volumes as are present in the Finder, I would recommend using NSWorkspace and its NSWorkspaceDidMountNotification and NSWorkspaceWillUnmountNotification notifications to learn when volumes are mounted and unmounted. Use -[NSFileManager mountedVolumeURLsIncludingResourceValuesForKeys:options:] with NSVolumeEnumerationSkipHiddenVolumes. You might want to use -getResourceValue:forKey:error: with NSURLVolumeIsBrowsableKey, too, since I'm not sure that non-browsable is synonymous with hidden.