Default location for configuration files - MacOS?

て烟熏妆下的殇ゞ 提交于 2019-12-10 20:01:54

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/15677388/default-location-for-configuration-files-macos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!