After debugging for two hours we have moved forward a small step.
There is a bug in Free Pascal's DBF tool. On Mac OS X, it cannot find any file when run from Terminal, since the default working directory is the current user directory (~), rather than the program's directory. (Interestingly, this is different, if the program is launched from Lazarus; here, the working directory IS the folder, where the program is located.)
By changing the procedure
GetDBFList in the DBF tool to
procedure GetDBFList(Results: TStringList);
// Gets list of all .dbf files in a directory and its subdirectories.
var
r: TSearchRec;
{$IFDEF DARWIN}
thePath: String;
{$ENDIF}
begin
{$IFDEF DARWIN}
thePath := ParamStr(0);
thePath := ExtractFileDir(thePath);
if not SetCurrentDir(thePath) then
writeln('Error setting path to ' + thePath);
{$ENDIF}
results.Clear;
if FindFirst('*.dbf', faAnyFile -
{$WARNINGS OFF}
faVolumeID - faSymLink
{$WARNINGS ON}
, r) = 0 then
begin
repeat
if (r.Attr and faDirectory) <> faDirectory then
begin
results.add(expandfilename(r.Name));
end;
until (FindNext(r) <> 0);
findclose(r);
end;
end;
the demo file can be found. The program then returns
*** Opening: /....................../fcl-db/examples/Client.dbf
Database tablelevel: 7
Database codepage: 1252
There is still another bug, since the DBF tool doesn't find the DBF files that it created with the option
--createdbf. The reason is that the files have an uppercase "DBF" extension, but the function
FindFirst doesn't find them when searching for '*.dbf'. This is a bug in
FindFirst, since the used file system is case-insensitive.
There is also still the bug in the DBase Test program that seems to be independent from the bug in the DBF tool.
Edit: I have reported both bugs in the FPC bug tracker (issue IDs
0027017 and
0027018).