diff --git a/components/lazutils/lazfileutils.inc b/components/lazutils/lazfileutils.inc index e709e2e27b..a9bf47e48a 100644 --- a/components/lazutils/lazfileutils.inc +++ b/components/lazutils/lazfileutils.inc @@ -3,12 +3,18 @@ function ResolveDots(const AFilename: string): String; //trim double path delims and expand special dirs like .. and . -//on Windows change also '/' to '\' +//on Windows change also '/' to '\' except for filenames starting with '\\?\' var SrcPos, DestPos, l, DirStart: integer; c: char; MacroPos: LongInt; + {$ifdef windows} + CannotTouchSeps: Boolean; + {$endif} begin Result:=AFilename; + {$ifdef windows} + CannotTouchSeps := Pos('\\?\', AFilename) = 1; + {$endif} l:=length(AFilename); SrcPos:=1; @@ -20,7 +26,7 @@ begin c:=AFilename[SrcPos]; {$ifdef windows} //change / to \. The WinApi accepts both, but it leads to strange effects in other places - if (c='/') then c := PathDelim; + if (c='/') and not CannotTouchSeps then c := PathDelim; {$endif} // check for double path delims if (c=PathDelim) then begin @@ -30,7 +36,7 @@ begin {$ELSE} if (DestPos>1) {$ENDIF} - and (Result[DestPos-1]=PathDelim) then begin + and (Result[DestPos-1]=PathDelim) and not CannotTouchSeps then begin // skip second PathDelim continue; end; @@ -127,7 +133,7 @@ begin c:=AFilename[SrcPos]; {$ifdef windows} //change / to \. The WinApi accepts both, but it leads to strange effects in other places - if (c='/') then c := PathDelim; + if (c='/') and not CannotTouchSeps then c := PathDelim; {$endif} if c=PathDelim then break; until false;