问题
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