Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moivhod

macrumors newbie
Original poster
Apr 8, 2017
12
0
I'm coding a cross-platform installation app which checks free disk space before extracting files. It's all easy with Windows system as it tags each hard drive with a letter. But how should my app deal with several hard drivers in Mac OS? How are they tagged? How can it refer to a HD chosen by user?

So far my app uses the info from Terminal to calculate the free space, but this trick works so far only with the main hard drive. If user chooses, say, and external disk my app does wrong calculation.
 
Look at this documentation: https://developer.apple.com/documen...ountedvolumeurlsincludingresour?language=objc

Most things you want to work with will be hanging off of NSFileManager in one way or another. But you will definitely need to be writing your own UI of some kind to handle selection.

Although, as someone who's done some work in this space, it'd be easier to try to make a tool that could generate the platform native installer for each platform instead of trying to do custom installation tooling all the way through. If for personal/internal use, that's one thing (although I've always just generated MSIs and PKGs even then).

But if this is for public consumption, it's worth considering the user trust side of things as well. Especially if this particular installer needs to elevate (or even just needs the permissions of an admin user) to do some of the work. Having mucked with elevation/installation on both platforms, getting it right (i.e. secure/safe/reliable) is tricky enough that I'd much rather let Microsoft/Apple own the security risks of the installer tools, and just leverage them as much as possible.
 
  • Like
Reactions: 0002378
The underlying Unix call is statfs(). It will give you information about the underlying file system corresponding to the file path you give it. That interface is going to be same across Unix-based operating systems like MacOS, Linux, etc.
You can ask the shell about it: man 2 statfs
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.