function getAliasPath(const AliasName: string): string;
var
SAlias: DBINAME;
Desc: DBDesc;
Params: TStrings;
begin
result := AliasName;
if DirectoryExists(AliasName) and (Pos(':\', AliasName) > 0 ) then Exit;
if not Session.IsAlias(AliasName) then Exit;
StrPLCopy(SAlias, AliasName, SizeOf(SAlias) - 1);
AnsiToOem(SAlias, SAlias);
fillchar(Desc, sizeof(Desc), 0);
try
if not Session.Active then Session.Active := True;
Check(DbiGetDatabaseDesc(SAlias, @Desc))
except
try
Session.OpenDatabase(AliasName);
Check(DbiGetDatabaseDesc(SAlias, @Desc))
except
end;
end;
if StrIComp(Desc.szDbType, szCFGDBSTANDARD) = 0
then begin
OemToAnsi(Desc.szPhyName, Desc.szPhyName);
result := StrPas(Desc.szPhyName);
end
else begin
Params := TStringList.Create;
try
{$IFDEF WIN32}
Session.Active := True;
{$ENDIF}
Session.GetAliasParams(AliasName, Params);
result := Params.Values['SERVER NAME'];
finally
Params.Free;
end;
end;
end;
function FullTablePath(Table : TTable) : string;
begin
try
result := Table.TableName;
if Pos('\', Table.TableName) = 0
then result := AddBackSlash(getAliasPath(Table.DataBaseName)) + ExtractFileName(Table.TableName);
if Length(ExtractFileExt(result)) < 3
then case Table.TableType of
ttASCII : result := ChangeFileExt(result, '.TXT');
ttDBase,
ttFoxPro : result := ChangeFileExt(result, '.DBF')
else if not FileExists(result) and FileExists(ChangeFileExt(result, '.DB'))
then result := ChangeFileExt(result, '.DB');
end;
except
end;
end;