Hi guys, No more new snippets these days?

I've got a new one. This routine concatenates two paths. The first is the basePath and the second is a path relative to this basepath. It handles "../" to jump to the parent directory.
My string programming skills are not that great, so I guess there's room for improvement.

[pascal]
function ConcatenatePaths(aBasePath, aRelativePath: String): String;
const
SEPARATORS = ['\','/'];
SEPARATOR = '/';
var
Name: String;
I: Integer;
begin
//Trim redundant slashes
if aRelativePath[1] in SEPARATORS then
aRelativePath := RightStr(aRelativePath, Length(aRelativePath)-1 );
if aBasePath[Length(aBasePath)] in SEPARATORS then
aBasePath := LeftStr(aBasePath, Length(aBasePath)-1 );

while Length(aRelativePath) > 0 do
begin
Name := Copy(aRelativePath, 1, 3);
if (Name = '../') or (Name = '..\') then
begin
for I := Length(aBasePath) downto 1 do
if aBasePath[I] in SEPARATORS then
begin
aBasePath := Copy(aBasePath, 1, I-1);
Break;
end;
aRelativePath := Copy(aRelativePath, 4, Length(aRelativePath)-3);
end
else
Break;
end;

Result := aBasePath + SEPARATOR + aRelativePath;
end;
[/pascal]

For example:

E:\some\groovy\file\path\to\somewhere + '..\..\..\myfile.txt'

results in:

E:\some\groovy\file\myfile.txt'
Now it's your turn again.