function GetApplicationPath : string;
begin
{$IFDEF DARWIN}
result := Copy(Application.ExeName, 1, Pos(ApplicationName + '.app', Application.ExeName) - 1);
{$ELSE}
Result := Application.Location;
{$ENDIF}
Result := IncludeTrailingPathDelimiter(Result);
end;
function GetAbsolutePathFromApp(SearchPath : String) : String;
Var
RelTag : String;
AppPath : String;
TmpRelPath : String;
cnt,i : Integer;
begin
RelTag := '..' + pathdelim;
AppPath := GetApplicationPath;
TmpRelPath := FixPathDelimiter(SearchPath);
if (Pos(RelTag, TmpRelPath) > 0) then
begin
cnt := 0;
while (Pos(RelTag, TmpRelPath) > 0) do
begin
TmpRelPath := Copy(TmpRelPath,4,Length(TmpRelPath));
inc(cnt);
end;
if cnt > 0 then
begin
for i:= 1 to cnt do
begin
AppPath := ExpandFileName(IncludeTrailingPathDelimiter(AppPath) + '..');
end;
end;
Result := IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(AppPath) + TmpRelPath);
end
else
begin
Result := IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(AppPath) + SearchPath);
end;
end;