Question: Code a Custom ExtractBasePath Delphi Function
Challenge: a custom Delphi function, ExtractBasePath, should take 2 path names (directory or file) and should return the base / common path for the two paths provided.
The code is submitted for the ExtractBasePath Delphi Challenge
Answer:
ExtractBasePath entry by Vlad Man:
Explore the list of all accepted entries for ExtractBasePath Delphi challenge.
Challenge: a custom Delphi function, ExtractBasePath, should take 2 path names (directory or file) and should return the base / common path for the two paths provided.
The code is submitted for the ExtractBasePath Delphi Challenge
Answer:
ExtractBasePath entry by Vlad Man:
function ExtractBasePath(const path1, path2: string): string; var   j: Integer;   vStrLength: Integer;   vLastDelemiterIndex: Integer; begin   Result := '';  if Length(path1) > Length(path2) then     vStrLength := Length(path2)   else     vStrLength := Length(path1) ;  for j := 1 to vStrLength do     if path1[j] = path2[j] then       Result := Result + path1[j]     else       Break;  vLastDelemiterIndex := LastDelimiter('\', Result) ;   Delete(Result, vLastDelemiterIndex + 1, Length(Result) - vLastDelemiterIndex) ; end;
Explore the list of all accepted entries for ExtractBasePath Delphi challenge.
SHARE