mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 17:49:14 +02:00
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 -
This commit is contained in:
parent
8c69afc2a9
commit
bdaf2d9c6e
@ -3,12 +3,18 @@
|
|||||||
|
|
||||||
function ResolveDots(const AFilename: string): String;
|
function ResolveDots(const AFilename: string): String;
|
||||||
//trim double path delims and expand special dirs like .. and .
|
//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;
|
var SrcPos, DestPos, l, DirStart: integer;
|
||||||
c: char;
|
c: char;
|
||||||
MacroPos: LongInt;
|
MacroPos: LongInt;
|
||||||
|
{$ifdef windows}
|
||||||
|
CannotTouchSeps: Boolean;
|
||||||
|
{$endif}
|
||||||
begin
|
begin
|
||||||
Result:=AFilename;
|
Result:=AFilename;
|
||||||
|
{$ifdef windows}
|
||||||
|
CannotTouchSeps := Pos('\\?\', AFilename) = 1;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
l:=length(AFilename);
|
l:=length(AFilename);
|
||||||
SrcPos:=1;
|
SrcPos:=1;
|
||||||
@ -20,7 +26,7 @@ begin
|
|||||||
c:=AFilename[SrcPos];
|
c:=AFilename[SrcPos];
|
||||||
{$ifdef windows}
|
{$ifdef windows}
|
||||||
//change / to \. The WinApi accepts both, but it leads to strange effects in other places
|
//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}
|
{$endif}
|
||||||
// check for double path delims
|
// check for double path delims
|
||||||
if (c=PathDelim) then begin
|
if (c=PathDelim) then begin
|
||||||
@ -30,7 +36,7 @@ begin
|
|||||||
{$ELSE}
|
{$ELSE}
|
||||||
if (DestPos>1)
|
if (DestPos>1)
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
and (Result[DestPos-1]=PathDelim) then begin
|
and (Result[DestPos-1]=PathDelim) and not CannotTouchSeps then begin
|
||||||
// skip second PathDelim
|
// skip second PathDelim
|
||||||
continue;
|
continue;
|
||||||
end;
|
end;
|
||||||
@ -127,7 +133,7 @@ begin
|
|||||||
c:=AFilename[SrcPos];
|
c:=AFilename[SrcPos];
|
||||||
{$ifdef windows}
|
{$ifdef windows}
|
||||||
//change / to \. The WinApi accepts both, but it leads to strange effects in other places
|
//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}
|
{$endif}
|
||||||
if c=PathDelim then break;
|
if c=PathDelim then break;
|
||||||
until false;
|
until false;
|
||||||
|
Loading…
Reference in New Issue
Block a user