Background: I'm trying to come up with a patch for macOS so that the "correct" path for GetAppConfigDir is returned (
https://bugs.freepascal.org/view.php?id=20706 - ignore the function proposed there as it uses the File Manager API which is deprecated in macOS 10.8 and later).
From osutil.inc:
Function DGetAppConfigDir(Global : Boolean) : String;
begin
Result:=ExcludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0)));
end;
Where does the Global boolean get actioned?
{ ---------------------------------------------------------------------
Fallback implementations for AppConfigDir implementation.
---------------------------------------------------------------------}
{
If a particular OS does it different:
- set the HAVE_OSCONFIG define before including sysutils.inc.
- implement the functions.
Default config assumes a DOS-like configuration.
}
{$ifndef HAS_OSCONFIG}
Function GetAppConfigDir(Global : Boolean) : String;
begin
Result:=DGetAppConfigDir(Global);
end;
1) Is the HAVE_OSCONFIG in the comment wrong as the code uses HAS_OSCONFIG ?
2) How to specify darwin? Obviously {$if define(darwin)} would do it, but in the context of using HAS/HAVE_OSCONFIG how does one do it? I couldn't see any examples in the code. I'm guessing that in sysutils.inc:
{$if define(darwin)}
Function GetAppConfigDir(Global : Boolean) : String;
begin
// fill in body
end;
Function GetAppConfigFile(Global : Boolean; SubDir : Boolean) : String;
begin
// fill in body
end;
{$define HAS_OSCONFIG}
{$endif darwin}
{ OS utility code }
{$i osutil.inc}
Am I close?
3) What does "Default config assumes a DOS-like configuration." mean?
Still in osutil.inc, should not:
Function GetAppConfigFile(Global : Boolean) : String;
begin
Result:=GetAppConfigFile(Global,False);
end;
in fact be:
Function DGetAppConfigFile(Global : Boolean) : String;
begin
Result:=GetAppConfigFile(Global,False);
end;
That is, the D prefix is missing on the function definition?