Creating ApplicationProperties sometime fails

My plugin writes a property file at startup or reads it if its already available. A few users on OSX(10.8 ) do have the problem that nothing happens and the plugin can not create the folders and the property file.

I use following code to create/read the file:

[code]ApplicationProperties applicationProperties;

options.applicationName = “PRODUCTNAME”;
options.commonToAllUsers = true;
options.filenameSuffix = “xml”;
options.folderName = “COMPANYNAME”;
options.storageFormat = PropertiesFile::storeAsXML;
options.ignoreCaseOfKeyNames = true;
options.osxLibrarySubFolder = “Application Support”;

applicationProperties.setStorageParameters(options);
applicationProperties.getCommonSettings(true);[/code]

The file should be created in following folder:

/Library/Application Support/COMPANYNAME/PRODUCTNAME.xml or USERNAME/Library/Application Support/COMPANYNAME/PRODUCTNAME.xml
Is this a security issue and how can i make sure that the plugin can create the file on every system?

Any help is welcome.

Is it possible that i have to call closeFiles() or saveIfNeeded() to make sure the files will be saved?

I’d strongly suggest not trying to use the common settings - writing to /Library is almost certain to be read-only, unless you’re running with root permissions.

And yes, you might want to call saveIfNeeded() to make sure it gets flushed after writing something important to it.

[quote=“jules”]I’d strongly suggest not trying to use the common settings - writing to /Library is almost certain to be read-only, unless you’re running with root permissions.

And yes, you might want to call saveIfNeeded() to make sure it gets flushed after writing something important to it.[/quote]
Thanks for that info.

Jules is right, and the policy changed since Lion (10.7) included: /Library/Application Support/ and its subdirectories are now read only, while the same path starting from the user home directory is also writeable.

The common application data directory /Library/Application Support/yourapplication/ should only contain read-only files that are put there by the installer (manual, resources, etc), while settings and customization should be stored (per user) in their ~/Library/Application Support/yourapplication/ folder