From 2fdee21c44d16fa2a521380672f8868565bb4df5 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Mon, 29 Oct 2007 23:09:04 +0000 Subject: fixed build error since build#USDX-LAZLIN-65 doh :( git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@542 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/USongs.pas | 111 ++++++++++++++++++++++++++++++------------- 1 file changed, 77 insertions(+), 34 deletions(-) (limited to 'Game') diff --git a/Game/Code/Classes/USongs.pas b/Game/Code/Classes/USongs.pas index e3c54ac4..5ce35201 100644 --- a/Game/Code/Classes/USongs.pas +++ b/Game/Code/Classes/USongs.pas @@ -134,14 +134,15 @@ end; procedure TSongs.BrowseDir(Dir: widestring); var - SR: TSearchRecW; // for parsing Songs Directory SLen: integer; - {$ifndef win32} - TheDir : pdir; - ADirent :pDirent; - Entry : Longint; - info : stat; + {$ifdef win32} + SR: TSearchRecW; // for parsing Songs Directory + {$else} // This should work on all posix systems. + TheDir : pdir; + ADirent : pDirent; + Entry : Longint; + info : stat; {$endif} begin {$ifdef win32} @@ -155,6 +156,37 @@ begin until FindNextw(SR) <> 0; end; // if FindClosew(SR); + + if FindFirstW(Dir + '*.txt', 0, SR) = 0 then + begin + repeat + SLen := BrowsePos; + + Song[SLen].Path := Dir; + Song[SLen].Folder := Copy(Dir, Length(SongPath)+1, 10000); + Song[SLen].Folder := Copy(Song[SLen].Folder, 1, Pos( PathDelim , Song[SLen].Folder)-1); + Song[SLen].FileName := SR.Name; + + if (AnalyseFile(Song[SLen]) = false) then + Dec(BrowsePos) + else + begin + if Song[SLen].Cover = '' then + Song[SLen].Cover := FindSongFile(Dir, '*[CO].jpg'); + end; + + //Change Length Only every 50 Entrys + Inc(BrowsePos); + + if (BrowsePos mod 50 = 0) AND (BrowsePos <> 0) then + begin + SetLength(Song, Length(Song) + 50); + end; + + until FindNextW(SR) <> 0; + end; // if FindFirst + FindCloseW(SR); + {$else} // Itterate the Songs Directory... ( With unicode capable functions for linux ) TheDir := opendir( Dir ); // JB_Unicode - linux @@ -175,39 +207,50 @@ begin end; Until ADirent=Nil; end; - {$endif} - -// Log.LogStatus('Parsing directory: ' + Dir + SR.Name, 'LoadSongList'); + + - if FindFirstW(Dir + '*.txt', 0, SR) = 0 then - begin - repeat - SLen := BrowsePos; + TheDir := opendir( Dir ); // JB_Unicode - linux + if TheDir <> nil then + begin + repeat + ADirent := ReadDir(TheDir); + + if ( ADirent <> Nil ) AND + ( pos( '.txt', ADirent^.name ) > -1 ) then + begin + SLen := BrowsePos; + + Song[SLen].Path := Dir; + Song[SLen].Folder := Copy(Dir, Length(SongPath)+1, 10000); + Song[SLen].Folder := Copy(Song[SLen].Folder, 1, Pos( PathDelim , Song[SLen].Folder)-1); + Song[SLen].FileName := ADirent^.name; + + if (AnalyseFile(Song[SLen]) = false) then + Dec(BrowsePos) + else + begin + if Song[SLen].Cover = '' then + Song[SLen].Cover := FindSongFile(Dir, '*[CO].jpg'); + end; + + //Change Length Only every 50 Entrys + Inc(BrowsePos); + + if (BrowsePos mod 50 = 0) AND (BrowsePos <> 0) then + begin + SetLength(Song, Length(Song) + 50); + end; + end; - Song[SLen].Path := Dir; - Song[SLen].Folder := Copy(Dir, Length(SongPath)+1, 10000); - Song[SLen].Folder := Copy(Song[SLen].Folder, 1, Pos( PathDelim , Song[SLen].Folder)-1); - Song[SLen].FileName := SR.Name; + Until ADirent=Nil; + end; // if FindFirst - if (AnalyseFile(Song[SLen]) = false) then - Dec(BrowsePos) - else - begin - if Song[SLen].Cover = '' then - Song[SLen].Cover := FindSongFile(Dir, '*[CO].jpg'); - end; + {$endif} + +// Log.LogStatus('Parsing directory: ' + Dir + SR.Name, 'LoadSongList'); - //Change Length Only every 50 Entrys - Inc(BrowsePos); - - if (BrowsePos mod 50 = 0) AND (BrowsePos <> 0) then - begin - SetLength(Song, Length(Song) + 50); - end; - until FindNextW(SR) <> 0; - end; // if FindFirst - FindCloseW(SR); end; procedure TSongs.Sort(Order: integer); -- cgit v1.2.3