From fba9a67e3718a65594dc7969dac952ce5cca99d8 Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Thu, 8 Nov 2007 23:18:12 +0000 Subject: Fixed song loading on Windows. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@601 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatformWindows.pas | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'Game/Code/Classes') diff --git a/Game/Code/Classes/UPlatformWindows.pas b/Game/Code/Classes/UPlatformWindows.pas index f78b87ec..7e65d700 100644 --- a/Game/Code/Classes/UPlatformWindows.pas +++ b/Game/Code/Classes/UPlatformWindows.pas @@ -103,32 +103,33 @@ Function TPlatform.DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs var i : Integer; SR : TSearchRecW; + lAttrib : Integer; begin i := 0; Filter := LowerCase(Filter); - if ReturnAllSubDirs then begin - if FindFirstW(Dir + '*', faDirectory, SR) = 0 then - repeat - if (SR.Name <> '.') and (SR.Name <> '..') then + if FindFirstW(Dir + '*', faAnyFile or faDirectory, SR) = 0 then + repeat + if (SR.Name <> '.') and (SR.Name <> '..') then + begin + lAttrib := FileGetAttr(Dir + SR.name); + if ReturnAllSubDirs and ((lAttrib and faDirectory) <> 0) then begin SetLength( Result, i + 1); - Result[i].Name := SR.Name; + Result[i].Name := SR.name; Result[i].IsDirectory := true; Result[i].IsFile := false; i := i + 1; + end + else if (Length(Filter) = 0) or (Pos( Filter, LowerCase(SR.Name)) > 0) then + begin + SetLength( Result, i + 1); + Result[i].Name := SR.Name; + Result[i].IsDirectory := false; + Result[i].IsFile := true; + i := i + 1; end; - until FindNextW(SR) <> 0; - FindCloseW(SR); - end; - - if FindFirstW(Dir + '*' + Filter, 0, SR) = 0 then - repeat - SetLength( Result, i + 1); - Result[i].Name := SR.Name; - Result[i].IsDirectory := true; - Result[i].IsFile := false; - i := i + 1; + end; until FindNextW(SR) <> 0; FindCloseW(SR); end; -- cgit v1.2.3