ADD: sort() in TFiles

This commit is contained in:
rich2014 2026-06-14 22:10:38 +08:00
commit dd3f3f70db
2 changed files with 16 additions and 2 deletions

View file

@ -864,7 +864,7 @@ begin
strings.AddObject( self.GetFileName(f), attr );
end;
if strings.Count > 0 then begin
if strings.Count > 1 then begin
case sort of
fstAlphabet: strings.CustomSort(@FilesSortAlphabet);
fstFoldersFirst: strings.CustomSort(@FilesSortFoldersFirst);

View file

@ -242,6 +242,8 @@ type
procedure Delete(AtIndex: Integer);
procedure Clear;
procedure sort;
function allFilesAtSamePath: Boolean;
procedure setPathBaseOnAllFiles;
@ -251,7 +253,6 @@ type
property OwnsObjects: Boolean read FOwnsObjects write FOwnsObjects;
property Path: String read FPath write SetPath;
property Flat: Boolean read FFlat write FFlat;
end;
{en
@ -970,6 +971,19 @@ begin
FList.Clear;
end;
function simpleCompare(Item1, Item2: Pointer): Integer;
var
file1: TFile absolute Item1;
file2: TFile absolute Item2;
begin
Result:= CompareStr( file1.FullPath, file2.FullPath );
end;
procedure TFiles.sort;
begin
FList.Sort( @simpleCompare);
end;
function TFiles.allFilesAtSamePath: Boolean;
var
checkPath: String;