From bdaf2d9c6eaedb1081f19a439f225c8d1b0796a8 Mon Sep 17 00:00:00 2001 From: bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Wed, 4 Sep 2013 21:57:26 +0000 Subject: [PATCH] LazUtils: in ResolveDots() don't convert \\ or / if AFilename starts with \\?\ (As per MS Specs anything after that must be takne literally?) git-svn-id: trunk@42602 - --- components/lazutils/lazfileutils.inc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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;