This is not the first time this topic is discussed, but as a Mac user, something I'd like to fix.
The problem:
Both GetAppConfigDir and GetAppConfigFile return an inappropriate result for Mac OS X (per Apple guidelines).
jwdietrich posted a way to work around this in this
post.
I just modified this a little bit ...
function GetPreferencesFolder(Global:boolean): String;
{ platform-independend method to search for the location of preferences folder}
const
kMaxPath = 1024;
var
{$IFDEF LCLCarbon}
theError: OSErr;
theRef: FSRef;
{$ENDIF}
pathBuffer: PChar;
begin
{$IFDEF LCLCarbon}
try
pathBuffer := Allocmem(kMaxPath);
except on exception do exit;
end;
try
Fillchar(pathBuffer^, kMaxPath, #0);
Fillchar(theRef, Sizeof(theRef), #0);
if Global then // kLocalDomain
theError := FSFindFolder(kLocalDomain, kApplicationSupportFolderType, kDontCreateFolder, theRef)
else
theError := FSFindFolder(kUserDomain , kApplicationSupportFolderType, kDontCreateFolder, theRef);
if (pathBuffer <> nil) and (theError = noErr) then
begin
theError := FSRefMakePath(theRef, pathBuffer, kMaxPath);
if theError = noErr then GetPreferencesFolder := UTF8ToAnsi(StrPas(pathBuffer)) + '/';
end;
finally
Freemem(pathBuffer);
end
{$ELSE}
GetPreferencesFolder := GetAppConfigDir(false);
{$ENDIF}
{
User preferences live in the location returned by FSFindFolder(kUserDomain,kPreferencesFolderType).
User application support items live in the location returned by FSFindFolder(kUserDomain, kApplicationSupportFolderType).
Global preferences live in the location returned by FSFindFolder(kLocalDomain,kPreferencesFolderType).
Global application support items live in the location returned by FSFindFolder(kLocalDomain, kApplicationSupportFolderType).
}
end;
Since GetAppConfigDir/File does not distinguishes between "Preferences" and "Application Data", I picked "Application Data". One can argue this might not be the 100% correct solution, but at least it better than the current "~/.config" location, and one could even store INI files there (instead of properly using XML in "Preferences").
So I went look for the functions GetAppConfigDir and GetAppConfigFile (sysutils), to see if I can incorporate this code, but I cannot edit these files. Probably because they are part of FPC?
I'd love to help out and create a patch to address this issue. Would anyone be able to assist?