From 3c999bea6a60e6b58dc8e9a70c08898c4efea906 Mon Sep 17 00:00:00 2001 From: tobigun Date: Thu, 23 Jul 2009 20:36:14 +0000 Subject: Buggy DirectoryFindFiles() (used by BrowseTXT/XMLFiles) removed and replaced with TSongs.FindFilesByExtension() - DirectoryFindFiles() was not applicable as: - it found files that contained the extension anywhere in the file, e.g. file.txt.bak - was not recursive (caller had to explore subdirs himself) - was not correct if ReturnAllSubDirs=false, as it also returned matching directories with IsFile=true and IsDirectory=false git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1912 b956fd51-792f-4845-bead-9b4dfca2ff2c --- unicode/src/base/UCommon.pas | 51 -------------------------------------------- 1 file changed, 51 deletions(-) (limited to 'unicode/src/base/UCommon.pas') diff --git a/unicode/src/base/UCommon.pas b/unicode/src/base/UCommon.pas index 187c21fb..fa0faf3c 100644 --- a/unicode/src/base/UCommon.pas +++ b/unicode/src/base/UCommon.pas @@ -82,17 +82,6 @@ procedure ZeroMemory(Destination: pointer; Length: dword); function MakeLong(a, b: word): longint; {$ENDIF} -type - TDirectoryEntry = record - Name: IPath; - IsDirectory: boolean; - IsFile: boolean; - end; - - TDirectoryEntryArray = array of TDirectoryEntry; - -function DirectoryFindFiles(Dir: IPath; Filter: UTF8String; ReturnAllSubDirs: boolean): TDirectoryEntryArray; - // A stable alternative to TList.Sort() (use TList.Sort() if applicable, see below) procedure MergeSort(List: TList; CompareFunc: TListSortCompare); @@ -298,46 +287,6 @@ end; {$ENDIF} -function DirectoryFindFiles(Dir: IPath; Filter: UTF8String; ReturnAllSubDirs: Boolean): TDirectoryEntryArray; -var - i: integer; - Iter: IFileIterator; - FileInfo: TFileInfo; - FileName: IPath; - Attrib: integer; -begin - i := 0; - Filter := UTF8LowerCase(Filter); - - // search for all files and directories - Iter := FileSystem.FileFind(Dir.Append('*'), faAnyFile); - while (Iter.HasNext) do - begin - FileInfo := Iter.Next; - FileName := FileInfo.Name; - if (not FileName.Equals('.')) and (not FileName.Equals('..')) then - begin - Attrib := Dir.Append(FileName).GetAttr(); - if ReturnAllSubDirs and ((Attrib and faDirectory) <> 0) then - begin - SetLength(Result, i + 1); - Result[i].Name := FileName; - Result[i].IsDirectory := true; - Result[i].IsFile := false; - i := i + 1; - end - else if (Filter = '') or (Pos(Filter, LowerCase(FileName.ToUTF8)) > 0) then - begin - SetLength(Result, i + 1); - Result[i].Name := FileName; - Result[i].IsDirectory := false; - Result[i].IsFile := true; - i := i + 1; - end; - end; - end; -end; - {$IFDEF FPC} function RandomRange(aMin: integer; aMax: integer): integer; begin -- cgit v1.2.3