Search code examples
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.

  • Does Qt provide a built-in method for doing this? (QDesktopServices looked promising, but does not seem to provide this option.)
  • If not, what are the standard locations on Linux and Mac OS X systems for shared application data? Is /usr/share the correct place? Is there a standard at all?

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