mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-04 13:37:22 +01:00
Fix ChompLath for windows C:\
git-svn-id: trunk@34716 -
This commit is contained in:
parent
78dc85c389
commit
8fd4128a31
@ -852,15 +852,31 @@ end;
|
||||
|
||||
function ChompPathDelim(const Path: string): string;
|
||||
var
|
||||
Len: Integer;
|
||||
Len, MinLen: Integer;
|
||||
begin
|
||||
if Path = '' then
|
||||
exit;
|
||||
|
||||
Result:=Path;
|
||||
Len:=length(Result);
|
||||
while (Len>1) and (Result[Len]=PathDelim) do dec(Len);
|
||||
{$IFDEF HasUNCPaths}
|
||||
if (Len=1) and (Result[1]=PathDelim) then
|
||||
Len:=2; // keep UNC '\\', chomp 'a\' to 'a'
|
||||
{$ENDIF}
|
||||
if (Result[1]=PathDelim) then begin
|
||||
MinLen := 1;
|
||||
{$IFDEF HasUNCPaths}
|
||||
if (Len >= 2) and (Result[2]=PathDelim) then
|
||||
MinLen := 2; // keep UNC '\\', chomp 'a\' to 'a'
|
||||
{$ENDIF}
|
||||
end
|
||||
else begin
|
||||
MinLen := 0;
|
||||
{$IFdef MSWindows}
|
||||
if (Len >= 3) and (Result[1] in ['a'..'z', 'A'..'Z']) and
|
||||
(Result[2] = ':') and (Result[3]=PathDelim)
|
||||
then
|
||||
MinLen := 3;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
while (Len > MinLen) and (Result[Len]=PathDelim) do dec(Len);
|
||||
if Len<length(Result) then
|
||||
SetLength(Result,Len);
|
||||
end;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user