aboutsummaryrefslogtreecommitdiffstats
path: root/unicode/src/base/USongs.pas
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-07-23 18:09:11 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-07-23 18:09:11 +0000
commit21c1082f916cc9a4d7be625c132e02b1fc1d8012 (patch)
treecf3c705058db9839ba80cebfaf0fe69086fa38f2 /unicode/src/base/USongs.pas
parent446eec893b7915d80a4504d40bbfc6f77cafa550 (diff)
downloadusdx-21c1082f916cc9a4d7be625c132e02b1fc1d8012.tar.gz
usdx-21c1082f916cc9a4d7be625c132e02b1fc1d8012.tar.xz
usdx-21c1082f916cc9a4d7be625c132e02b1fc1d8012.zip
- IPath integration
- BASS is now unicode compatible git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1875 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--unicode/src/base/USongs.pas68
1 files changed, 27 insertions, 41 deletions
diff --git a/unicode/src/base/USongs.pas b/unicode/src/base/USongs.pas
index 2b2bcf49..55ddc5e9 100644
--- a/unicode/src/base/USongs.pas
+++ b/unicode/src/base/USongs.pas
@@ -40,28 +40,26 @@ interface
{$ENDIF}
uses
+ SysUtils,
+ Classes,
{$IFDEF MSWINDOWS}
Windows,
DirWatch,
{$ELSE}
{$IFNDEF DARWIN}
- syscall,
+ syscall,
{$ENDIF}
baseunix,
UnixType,
{$ENDIF}
- SysUtils,
- Classes,
UPlatform,
ULog,
UTexture,
UCommon,
- {$IFDEF DARWIN}
- cthreads,
- {$ENDIF}
{$IFDEF USE_PSEUDO_THREAD}
- PseudoThread,
+ PseudoThread,
{$ENDIF}
+ UPath,
USong,
UCatCovers;
@@ -107,11 +105,10 @@ type
procedure LoadSongList; // load all songs
- procedure BrowseDir(Dir: widestring); // should return number of songs in the future
- procedure BrowseTXTFiles(Dir: widestring);
- procedure BrowseXMLFiles(Dir: widestring);
+ procedure BrowseDir(Dir: IPath); // should return number of songs in the future
+ procedure BrowseTXTFiles(Dir: IPath);
+ procedure BrowseXMLFiles(Dir: IPath);
procedure Sort(Order: integer);
- function FindSongFile(Dir, Mask: widestring): widestring;
property Processing: boolean read fProcessing;
end;
@@ -165,6 +162,7 @@ uses
UIni,
UPathUtils,
UNote,
+ UFilesystem,
UUnicodeUtils;
constructor TSongs.Create();
@@ -239,7 +237,7 @@ begin
// browse directories
for I := 0 to SongPaths.Count-1 do
- BrowseDir(SongPaths[I]);
+ BrowseDir(SongPaths[I] as IPath);
if assigned(CatSongs) then
CatSongs.Refresh;
@@ -271,13 +269,13 @@ begin
Resume();
end;
-procedure TSongs.BrowseDir(Dir: widestring);
+procedure TSongs.BrowseDir(Dir: IPath);
begin
BrowseTXTFiles(Dir);
BrowseXMLFiles(Dir);
end;
-procedure TSongs.BrowseTXTFiles(Dir: widestring);
+procedure TSongs.BrowseTXTFiles(Dir: IPath);
var
i: integer;
Files: TDirectoryEntryArray;
@@ -285,27 +283,27 @@ var
begin
try
- Files := Platform.DirectoryFindFiles(Dir, '.txt', true)
+ Files := DirectoryFindFiles(Dir, '.txt', true)
except
- Log.LogError('Couldn''t deal with directory/file: ' + Dir + ' in TSongs.BrowseTXTFiles')
+ Log.LogError('Couldn''t deal with directory/file: ' + Dir.ToNative + ' in TSongs.BrowseTXTFiles')
end;
for i := 0 to Length(Files) - 1 do
begin
if Files[i].IsDirectory then
begin
- BrowseTXTFiles(Dir + Files[i].Name + PathDelim); //Recursive Call
+ BrowseTXTFiles(Dir.Append(Files[i].Name, pdAppend)); //Recursive Call
end
else
begin
- lSong := TSong.create(Dir + Files[i].Name);
+ lSong := TSong.Create(Dir.Append(Files[i].Name));
if lSong.Analyse then
SongList.add(lSong)
else
begin
- Log.LogError('AnalyseFile failed for "' + Files[i].Name + '".');
- freeandnil(lSong);
+ Log.LogError('AnalyseFile failed for "' + Files[i].Name.ToNative + '".');
+ FreeAndNil(lSong);
end;
end;
@@ -314,7 +312,7 @@ begin
end;
-procedure TSongs.BrowseXMLFiles(Dir: widestring);
+procedure TSongs.BrowseXMLFiles(Dir: IPath);
var
i: integer;
Files: TDirectoryEntryArray;
@@ -322,26 +320,26 @@ var
begin
try
- Files := Platform.DirectoryFindFiles(Dir, '.xml', true)
+ Files := DirectoryFindFiles(Dir, '.xml', true)
except
- Log.LogError('Couldn''t deal with directory/file: ' + Dir + ' in TSongs.BrowseXMLFiles')
+ Log.LogError('Couldn''t deal with directory/file: ' + Dir.ToNative + ' in TSongs.BrowseXMLFiles')
end;
for i := 0 to Length(Files) - 1 do
begin
if Files[i].IsDirectory then
begin
- BrowseXMLFiles(Dir + Files[i].Name + PathDelim); // Recursive Call
+ BrowseXMLFiles(Dir.Append(Files[i].Name, pdAppend)); // Recursive Call
end
else
begin
- lSong := TSong.create(Dir + Files[i].Name);
+ lSong := TSong.Create(Dir.Append(Files[i].Name));
if lSong.AnalyseXML then
SongList.add(lSong)
else
begin
- Log.LogError('AnalyseFile failed for "' + Files[i].Name + '".');
+ Log.LogError('AnalyseFile failed for "' + Files[i].Name.ToNative + '".');
freeandnil(lSong);
end;
@@ -377,7 +375,7 @@ end;
function CompareByFolder(Song1, Song2: Pointer): integer;
begin
- Result := CompareText(TSong(Song1).Folder, TSong(Song2).Folder);
+ Result := UTF8CompareText(TSong(Song1).Folder, TSong(Song2).Folder);
end;
function CompareByLanguage(Song1, Song2: Pointer): integer;
@@ -419,18 +417,6 @@ begin
MergeSort(SongList, CompareFunc);
end;
-function TSongs.FindSongFile(Dir, Mask: widestring): widestring;
-var
- SR: TSearchRec; // for parsing song directory
-begin
- Result := '';
- if FindFirst(Dir + Mask, faDirectory, SR) = 0 then
- begin
- Result := SR.Name;
- end; // if
- FindClose(SR);
-end;
-
procedure TCatSongs.SortSongs();
begin
case Ini.Sorting of
@@ -603,7 +589,7 @@ begin
end;
sFolder: begin
- if (CompareText(CurCategory, CurSong.Folder) <> 0) then
+ if (UTF8CompareText(CurCategory, CurSong.Folder) <> 0) then
begin
CurCategory := CurSong.Folder;
// add folder tab
@@ -831,7 +817,7 @@ begin
begin
case Filter of
fltAll:
- TmpString := Song[I].Artist + ' ' + Song[i].Title + ' ' + UTF8Encode(Song[i].Folder);
+ TmpString := Song[I].Artist + ' ' + Song[i].Title + ' ' + Song[i].Folder;
fltTitle:
TmpString := Song[I].Title;
fltArtist: