From deead46265467acd1caf7e1c26453fe82286e3d7 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Sun, 16 Aug 2009 12:51:59 +0000 Subject: [PATCH] Fixes FileUtil.FileSize for wince and adds unicode filename support in win32 git-svn-id: trunk@21243 - --- lcl/include/fileutil.inc | 33 +++++++++++++------------- lcl/interfaces/wince/wincewsdialogs.pp | 3 ++- lcl/shellctrls.pas | 8 +++---- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/lcl/include/fileutil.inc b/lcl/include/fileutil.inc index a152adfc52..8b09e29257 100644 --- a/lcl/include/fileutil.inc +++ b/lcl/include/fileutil.inc @@ -840,30 +840,31 @@ function FileSize(const Filename: string): int64; {$IFDEF Unix} var st: baseunix.stat; -{$ELSE} -var - FileInfo: TSearchRec; -{$ENDIF} begin - {$IFDEF Unix} if not fpstat(pointer(Filename),st)>=0 then exit(-1); Result:=st.st_size; - {$ELSE} - {$IFDEF WINCE} - FileInfo.Name:=UTF8Decode(Filename); - {$ELSE} - FileInfo.Name:=UTF8ToSys(Filename); - {$ENDIF} - FileInfo.FindHandle:=Windows.FindFirstFile(Windows.LPTSTR(FileInfo.Name),FileInfo.FindData); - if FileInfo.FindHandle=Windows.Invalid_Handle_value then begin +end; +{$ELSE} +var + FindData: TWIN32FindDataW; + FindHandle: THandle; + Str: widestring; +begin + // Fix for the bug 14360: + // Don't assign the widestring to TSearchRec.name because it is of type + // string, which will generate a conversion to the system encoding + Str := UTF8Decode(Filename); + FindHandle:=Windows.FindFirstFileW(PWideChar(Str), FindData); + if FindHandle=Windows.Invalid_Handle_value then + begin Result:=-1; exit; end; - Result:=(int64(FileInfo.FindData.nFileSizeHigh) shl 32)+FileInfo.FindData.nFileSizeLow; - Windows.FindClose(FileInfo.FindHandle); - {$ENDIF} + Result:=(int64(FindData.nFileSizeHigh) shl 32)+FindData.nFileSizeLow; + Windows.FindClose(FindHandle); end; +{$ENDIF} {------------------------------------------------------------------------------ GetFileDescription diff --git a/lcl/interfaces/wince/wincewsdialogs.pp b/lcl/interfaces/wince/wincewsdialogs.pp index e0da15c2d5..4cc3865bf9 100644 --- a/lcl/interfaces/wince/wincewsdialogs.pp +++ b/lcl/interfaces/wince/wincewsdialogs.pp @@ -31,7 +31,7 @@ uses Windows, // LCL ShellCtrls, Forms, Dialogs, FileCtrl, Controls, ComCtrls, - LResources, ExtCtrls, Buttons, Graphics, + LResources, ExtCtrls, Buttons, Graphics, StdCtrls, // Widgetset WSDialogs, WSLCLClasses, InterfaceBase; @@ -187,6 +187,7 @@ begin ShellListView.Width := Width; ShellListView.Height := Height - ShellTreeView.Height - Panel.Height; ShellListView.ShellTreeView := ShellTreeView; + ShellListView.ScrollBars := ssNone; end; procedure TWinCEFileDialogForm.HandleOkClick(ASender: TObject); diff --git a/lcl/shellctrls.pas b/lcl/shellctrls.pas index 2df0737402..565cb1fa89 100644 --- a/lcl/shellctrls.pas +++ b/lcl/shellctrls.pas @@ -520,6 +520,7 @@ begin begin FRoot := Value; Clear; + Items.Clear; PopulateWithRoot(); end; end; @@ -551,15 +552,14 @@ begin inherited Create(AOwner); // Initial property values - + ViewStyle := vsReport; ObjectTypes := [otNonFolders]; - Self.Columns.Clear; + Self.Columns.Add; + Self.Columns.Add; Self.Columns.Add; Self.Column[0].Caption := 'Name'; - Self.Columns.Add; Self.Column[1].Caption := 'Size'; - Self.Columns.Add; Self.Column[2].Caption := 'Type'; // Initial sizes, necessary under Windows CE HandleResize(Self);