linuxmacosqtapplication-data

Shared data location for Linux and Mac OS X


On Windows, there is a standard location for application data that is shared in common with all users on the machine (i.e. in Vista/7, (root):\ProgramData). I'm looking for a way to get such a folder on other platforms using Qt.

[CLARIFICATION] This is for mutable data.


Solution

  • I don't know if Qt provides an API for that. Here's the OS X specific information.

    On OS X, it depends whether it's a GUI app or unix level support libraries. For a GUI app, it's the standard practice to have all the read-only data shared by all users inside the app bundle itself. Typically you have

      YourApp.app/
      YourApp.app/Contents
      YourApp.app/Contents/MacOS
      YourApp.app/Contents/MacOS/YouApp      .... this is the binary
      YourApp.app/Contents/Resources/        .... here are all the shared data
    

    The GUI presents the directory YourApp.app as the application itself, so that you can copy/move it around without any problem. If that's not possible, it's recommended to use the subdirectory of

    /Library/Application Support/name_of_your_app/
    

    for data shared among users.

    It's a bad idea to have a mutable, shared data among users on a machine; in general it's impossible due to the access restrictions. Note that a standard user might not have, and in fact usually does not have an administrative right to write into a shared location.

    For mutable data specific to a user, use

    ~/Library/Application Support/name_of_your_app/
    

    See this Apple guideline for more info.