From f3358d80502dfa54b933b7a679d4650e8cd66526 Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 6 Sep 2013 14:56:35 +0000 Subject: [PATCH] lazutils: fix compilation after cpstrrtl merge git-svn-id: trunk@42642 - --- components/lazutils/winlazfileutils.inc | 28 +++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/components/lazutils/winlazfileutils.inc b/components/lazutils/winlazfileutils.inc index 3f70ecd3c3..08fa0e4a0d 100644 --- a/components/lazutils/winlazfileutils.inc +++ b/components/lazutils/winlazfileutils.inc @@ -447,6 +447,9 @@ begin {$endif} end; +{$IF DEFINED(WinCE) OR (FPC_FULLVERSION>=20701)} + {$define FindData_W} +{$endif} function FindMatch(var f: TSearchRec) : Longint; @@ -467,14 +470,16 @@ begin { The structures are different at this point in win32 it is the ansi structure with a utf-8 string in wince it is a wide structure } - {$ifdef WinCE} - f.Name:=UTF8Encode(F.FindData.cFileName); + {$ifdef FindData_W} + f.Name:=UTF8Encode(UnicodeString(F.FindData.cFileName)); {$else} f.Name:=F.FindData.cFileName; {$endif} Result:=0; end; +{$IFNDEF FindData_W} + { This function does not really convert from wide to ansi, but from wide to a utf-8 encoded ansi version of the data structures in win32 and does nothing in wince @@ -485,9 +490,6 @@ var ws: WideString; an: AnsiString; begin - {$ifdef WinCE} - ansi := wide; - {$else} SetLength(ws, length(wide.cAlternateFileName)); Move(wide.cAlternateFileName[0], ws[1], length(ws)*2); an := AnsiString(ws); // no need to utf8 for cAlternateFileName (it's always ansi encoded) @@ -509,12 +511,12 @@ begin dwReserved0 := wide.dwReserved0; dwReserved1 := wide.dwReserved1; end; - {$endif} end; +{$ENDIF} function FindFirstWide(const Path: string; Attr: Longint; out Rslt: TSearchRec): Longint; var - find : TWIN32FINDDATAW; + find: TWIN32FINDDATAW; begin Rslt.Name:=Path; Rslt.Attr:=attr; @@ -528,18 +530,26 @@ begin Exit; end; { Find file with correct attribute } + {$IFNDEF FindData_W} FindWideToAnsi(find, Rslt.FindData); - Result:=FindMatch(Rslt); + {$ELSE} + Rslt.FindData := find; + {$IFEND} + Result := FindMatch(Rslt); end; function FindNextWide(var Rslt: TSearchRec): Longint; var - wide : TWIN32FINDDATAW; + wide: TWIN32FINDDATAW; begin if FindNextFileW(Rslt.FindHandle, wide) then begin + {$IFNDEF FindData_W} FindWideToAnsi(wide, Rslt.FindData); + {$ELSE} + Rslt.FindData := wide; + {$ENDIF} Result := FindMatch(Rslt); end else