mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 11:39:29 +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;
|
||||
//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;
|
||||
|
Loading…
Reference in New Issue
Block a user