Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default location for configuration files - MacOS?

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?

like image 311
DevSolar Avatar asked Mar 28 '13 08:03

DevSolar


People also ask

Where are Mac config files stored?

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.

Where are configuration files usually located?

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.

Where the configuration files are stored in your application?

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 .


2 Answers

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".

like image 54
cody Avatar answered Sep 30 '22 09:09

cody


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.

like image 38
Randy Howard Avatar answered Sep 30 '22 09:09

Randy Howard