In a cross-platform application, I am working with a configuration file that allows the user to override various defaults if he wishes to.
The problem I have is... where to place / look for this configuration file, especially with regards to MacOS X (which I never used and have no access to)? I know that MacOS X is based on Unix, but I also know that many things are done very much differently there...
My current choices:
Unix:
~/.config/<appname>/<appname>.cfg
Windows (shomewhat unsure about this one too, things seem to be all over the place here - %LOCALAPPDATA% or %USERPROFILE% seem to be valid choices too):
%APPDATA%/<appname>/<appname>.cfg
MacOS:
...?
Any comments, on MacOS or my other choices?
The registry is a hierarchical database included as part of Windows that can also store some config data as key-value pairs. For Mac OS X, the ~/Library folder is usually used, with /Library for global configs.
System-wide software often uses configuration files stored in /etc , while user applications often use a "dotfile" – a file or directory in the home directory prefixed with a period, which in Unix hides the file or directory from casual listing. Some configuration files run a set of commands upon startup.
These config files are typically placed under separate root directory than the rest of application code. For example, in case of Java they are typically under src/main/resources .
I think it must be ~/Library/Application Support/<appname>/<appname>.cfg
See the table in Mac App Programming Guide : "The Mac Application Environment" -> "Low-Level Details of the Runtime Environment" -> "The File System".
You can store it in the same manner you show for Unix/Linux above.
~
works the same way for home directories on OS X as UNIX platforms. Same goes for .
in names for hidden directories.
Given the cross-platform needs you describe, I would do it exactly the same way on OS X as in your UNIX example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With