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.
/usr/share
the correct place? Is there a standard at all?[CLARIFICATION] This is for mutable data.
Open System Preferences by clicking the Apple logo and selecting System Preferences. Click the Sharing icon and enable File Sharing. Click the Options button here and ensure “Share files and folders using SMB” is enabled. Use the Shared Folders column to choose additional folders to share.
The computer's Shared folder is located in Macintosh HD/Users. Your Public folder is located inside your Home folder, and your Drop Box folder is located inside your Public folder.
On your Mac, click the Finder icon in the Dock to open a Finder window. Choose View > Show Path Bar, or press the Option key to show the path bar momentarily. The location and nested folders that contain your file or folder are displayed near the bottom of the Finder window.
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.
The File System Hierarchy Standard suggest that /usr/share
should be used for read-only architecture independent data files, and /var/lib
should be used for state information pertaining to an application or the system.
You didn't specify whether you're referring to read-only or mutable state, but the wording of your question (specifically the comparison to %COMMONAPPDATA%
) suggests mutable state, in which case /var/lib
would be appropiate. Don't forget to have a user group with write rights to your subdirectory there available (or created by the package installation script) and have the sysadmin add the appropiate users to that group.
On Mac OS, one solution is to use the /Users/Shared directory, since it is read/write for all users, and is therefore mutable for everyone. Have to make sure any files you create in there are read/write for everyone too.
Or you can use app support as suggested by others, and making any files you need to be mutable read/write for everyone, but that means an admin needs to create them first, either through an installer or first run, which is a little ugly.
My company is using Users/Shared for exactly this purpose, but I don't know how "neat" it is considered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With