Equivalents of XDG_CONFIG_HOME and XDG_DATA_HOME on Mac OS X?

前端 未结 3 1020
花落未央
花落未央 2021-01-30 22:46

I am planning to develop a cross-platform script. On Linux and other operating systems, it will store configuration in XDG_CONFIG_HOME and data files (specifically,

3条回答
  •  遥遥无期
    2021-01-30 23:33

    Comparing Apple's documentation for the various paths to the XDG Base Directory specifications approximates to the following locations:

    • XDG_CONFIG_HOME ▶︎ ~/Library/Preferences/
    • XDG_DATA_HOME ▶︎ ~/Library/
    • XDG_CACHE_HOME ▶︎ ~/Library/Caches/

    Mapping XDG Base Directory Specification locations for "My App" on Mac OS X could look like this:

    • XDG_CONFIG_HOME ▶︎ ~/Library/Preferences/name.often.with.domain.myapp.plist
    • XDG_DATA_HOME ▶︎ ~/Library/My App/
    • XDG_CACHE_HOME ▶︎ ~/Library/Caches/My App/

    These mappings seem pretty reasonable but they aren't exact. Some kinds of cache or data may be appropriate for ~/Library/Application Support/My App, and other may be best in the temp locations or the App bundle. All of it is by convention and the same reasons for using the best XDG_ locations apply to using the best locations on the Mac OS X system.

    Your annoyance at ~/.myscript is in line with Apple's guidelines: "Don't pollute user space".

    References:

    • Mac OS X Reference Library: Where to Put Application Files
    • Mac OS X Reference Library: Important Java Directories on Mac OS X

提交回复
热议问题