I have come across an (outdated) code snippet that uses File Manager functions (included in Carbon) to locate the shared application Preferences folder (which in most cases is just "/Library/Preferences"). It is something like:
#include <Carbon/Carbon.h>
...
FSSpec spec = { 0 }; // data type which specifies name and location of a file or folder
FSRef ref; // data type which references in some sense a file or a folder
OSErr err = fnfErr;
// find a 'preferences' type folder (specified by kPreferencesFolderType)
// with the necessary permissions (specified by kUserDomain)
err = FindFolder(kUserDomain, ,
1, &spec.vRefNum, &spec.parID);
// operate some conversions to put the folder path inside a string where you can
// then append the app name to it.
FSpMakeFSRef(&spec, &ref);
FSRefMakePath(&ref, (UInt8*)filename, FL_PATH_MAX);
(kUserDomain
and kPreferencesFolderType
are enum values defined in CarbonCore/Folders.h.)
Unfortunately, many "FS" File Manager functions appear to be deprecated, especially those using FSSpec
(https://developer.apple.com/library/mac/documentation/Carbon/reference/File_Manager/Reference/reference.html).
I was therefore wondering: what would it be the current proper way to locate the application preferences folder (without hard wiring "Library/Preferences/AppName" into the code)? Thanks