0
votes

I'm a Python programmer that is trying to make a system of sorts that creates save data for a game I'm making, and I want it to be in different places in something like Ubuntu than I do macOS. As I don't have a macOS, and it's impossible to just up and get an ISO to get a macOS VM, I can't look through the files and folders and see what it has (or doesn't) that Linux does or doesn't.

I've tried looking all over to the point of attempting to get a hold of an ISO to build a VM in VirtualBox, but haven't been successful at all.

What files or folders does macOS have that Linux does, or vice versa?

2

2 Answers

1
votes

To complete the (excellent) answer from @Michael, here is the listing of the home and root directory after a fresh install on the latest stable release of MacOS System (10.14.2)

MacBook-Pro:~ max$ ls -al /
total 37
drwxr-xr-x  26 root  wheel   832 Jan  6 19:00 .
drwxr-xr-x  26 root  wheel   832 Jan  6 19:00 ..
-rw-rw-r--   1 root  admin  8196 Jan 13 07:11 .DS_Store
drwx------   5 root  admin   160 Jan  6 11:47 .Spotlight-V100
d-wx-wx-wt   2 root  wheel    64 Jan 14 06:39 .Trashes
----------   1 root  admin     0 Aug 18 06:53 .file
drwx------  11 root  admin   352 Jan 14 06:39 .fseventsd
drwxr-xr-x   2 root  wheel    64 Aug 18 06:53 .vol
drwxrwxr-x+ 39 root  admin  1248 Nov 30 12:49 Applications
drwxr-xr-x+ 60 root  wheel  1920 Nov 30 12:50 Library
drwxr-xr-x   2 root  wheel    64 Aug 18 06:53 Network
drwxr-xr-x@  5 root  wheel   160 Nov 30 12:46 System
drwxr-xr-x   5 root  admin   160 Jan  6 18:59 Users
drwxr-xr-x+  4 root  wheel   128 Jan 14 06:39 Volumes
drwxr-xr-x@ 37 root  wheel  1184 Nov 30 12:55 bin
drwxrwxr-t   2 root  admin    64 Aug 18 06:53 cores
dr-xr-xr-x   3 root  wheel  4301 Jan 14 06:39 dev
lrwxr-xr-x@  1 root  wheel    11 Jan  6 18:49 etc -> private/etc
dr-xr-xr-x   2 root  wheel     1 Jan 14 06:40 home
-rw-r--r--   1 root  wheel   313 Aug 18 10:03 installer.failurerequests
dr-xr-xr-x   2 root  wheel     1 Jan 14 06:40 net
drwxr-xr-x   6 root  wheel   192 Nov 30 12:50 private
drwxr-xr-x@ 64 root  wheel  2048 Jan  6 18:49 sbin
lrwxr-xr-x@  1 root  wheel    11 Jan  6 18:49 tmp -> private/tmp
drwxr-xr-x@  9 root  wheel   288 Nov 30 12:38 usr
lrwxr-xr-x@  1 root  wheel    11 Jan  6 18:49 var -> private/var

And the home dir:

MacBook-Pro:~ max$ ls -al ~
total 16
drwxr-xr-x+ 15 max    staff   480 Jan 14 06:43 .
drwxr-xr-x   5 root  admin   160 Jan  6 18:59 ..
-r--------   1 max    staff     7 Jan  6 18:59 .CFUserTextEncoding
drwx------   2 max    staff    64 Jan 14 06:40 .Trash
-rw-------   1 max    staff     0 Jan 13 07:11 .bash_history
drwx------  10 max    staff   320 Jan 14 06:40 .bash_sessions
-rw-------   1 max    staff   908 Jan 14 06:43 .viminfo
drwx------+  3 max    staff    96 Jan  6 18:59 Desktop
drwx------+  3 max    staff    96 Jan  6 18:59 Documents
drwx------+  3 max    staff    96 Jan  6 18:59 Downloads
drwx------@ 51 max    staff  1632 Jan 13 07:11 Library
drwx------+  3 max    staff    96 Jan  6 18:59 Movies
drwx------+  3 max    staff    96 Jan  6 18:59 Music
drwx------+  3 max    staff    96 Jan  6 18:59 Pictures
drwxr-xr-x+  4 max    staff   128 Jan  6 18:59 Public
1
votes

Application settings on macOS are ususally saved somewhere in ~/Library: Common places are ~/Library/Preferences/com.example.mycoolgame.plist for preferences (should be in plist format and "com.example.mycoolgame" should be a valid bundle ID that you own (you should own the domain)). The advantage/disadvantage of this path is that power users know about this directory and can edit the files there as they wish.

Then you have ~/Library/Caches for cached data. All cached data should be put somewhere under this directory. (Never use it for content that cannot be regenerated or redownloaded though.)

~/Library/ApplicationSupport/YourApplicationName/...: here you can basically do anything you like. It would be good if "YourApplicationName" would be globally unique in this case.. So better make it long. Users usually don't see the filesystem contents of anything below "~/Library", so there is no need for short names.

Of course, you can also put your savegames in ~/Documents/MyCoolGame/savegames and tell the user that you save the games there.

A gotcha (maybe): I'm not sure if system APIs expand "~" properly. I think probably not: Calling fopen with a path that starts with "~" would most likely not do the right thing. The users directory is located at something like "/Users/max", so "~" expands to "/Users/max" in the command line if the username is "max".

I can't answer your original question "What directories does Linux have that macOS doesn't?" because I don't have a Linux box at hand at the moment, and I don't think that it would be helpful for your use case.


For global data, there is also the "/Library" hierarchy.. But normal users don't have access to this place, so your game would need to ask for admin rights, which will make everything much more complicated, and this will feel user-unfriendly to macOS users. The macOS way is to have a self-contained application bundle and put all user-specific or temporary data into the appropriate place within the users home folder.