From 7c2f3b3ab27e25834974eb656921a0fff4ef5377 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 29 Nov 2009 18:00:30 +0100 Subject: Transform FillDirFiles input to allow sorting --- UCore.pas | 55 +++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) (limited to 'UCore.pas') diff --git a/UCore.pas b/UCore.pas index 1fec52c..34f8012 100644 --- a/UCore.pas +++ b/UCore.pas @@ -28,7 +28,7 @@ function FillPanel(List: TList; ListView: TGTKListView; Engine: TPanelEngine; Le procedure FindNextSelected(ListView: TGTKListView; DataList: TList; var Item1, Item2: string); procedure UnselectAll(ListView: TGTKListView; DataList: TList); -procedure FillDirFiles(Engine: TPanelEngine; List: TList; const APath: string); +procedure FillDirFiles(Engine: TPanelEngine; DestList: TList; InputFiles: TStringList; DoNotRecurse: boolean); function GetFileInfoSL(Engine: TPanelEngine; const APath: string): PDataItemSL; procedure DebugWriteListSL(List: TList); @@ -348,7 +348,7 @@ end; (********************************************************************************************************************************) (********************************************************************************************************************************) -procedure FillDirFiles(Engine: TPanelEngine; List: TList; const APath: string); +procedure FillDirFiles(Engine: TPanelEngine; DestList: TList; InputFiles: TStringList; DoNotRecurse: boolean); procedure FillDirFilesRecurse(const LocalPath: string; ALevel: integer); var LocalList: TList; @@ -367,7 +367,7 @@ procedure FillDirFiles(Engine: TPanelEngine; List: TList; const APath: string); ItemSL^.Stage1 := True; ItemSL^.IsOnRO := Engine.IsOnROMedium(string(Item^.FName)); ItemSL^.Level := ALevel; - List.Add(ItemSL); + DestList.Add(ItemSL); if Item^.IsDir then begin // Recurse to parent @@ -378,7 +378,7 @@ procedure FillDirFiles(Engine: TPanelEngine; List: TList; const APath: string); // Add end stage ItemSL := DuplicateDataItem(ItemSL); ItemSL^.Stage1 := False; - List.Add(ItemSL); + DestList.Add(ItemSL); end; end; end else begin @@ -390,31 +390,31 @@ procedure FillDirFiles(Engine: TPanelEngine; List: TList; const APath: string); end; var root: PDataItemSL; + i: integer; begin - root := GetFileInfoSL(Engine, APath); - if (root = nil) then begin - DebugMsg(['FillDirFiles: cannot stat ', APath]); - Exit; - end; - if (not root^.DataItem^.IsDir) then begin - DebugMsg(['FillDirFiles: path "', APath, '" is not a directory, cannot recurse.']); - FreeDataItem(root); - Exit; - end; - - // Add starting item - root^.Stage1 := True; - root^.Level := 1; - List.Add(root); - - // Recurse to child - FillDirFilesRecurse(APath, 2); + if InputFiles.Count = 0 then Exit; - // Add ending item - root := GetFileInfoSL(Engine, APath); - root^.Stage1 := False; - root^.Level := 1; - List.Add(root); + for i := 0 to InputFiles.Count - 1 do begin + root := GetFileInfoSL(Engine, InputFiles[i]); + if (root = nil) then begin + DebugMsg(['FillDirFiles: cannot stat ', InputFiles[i]]); + Exit; + end; + root^.Level := 1; + DestList.Add(root); + + if root^.DataItem^.IsDir then begin + // It's a directory, mark as starting item + root^.Stage1 := True; + // Recurse to child + FillDirFilesRecurse(InputFiles[i], 2); + // Add ending item + root := GetFileInfoSL(Engine, InputFiles[i]); + root^.Stage1 := False; + root^.Level := 1; + DestList.Add(root); + end; + end; end; function GetFileInfoSL(Engine: TPanelEngine; const APath: string): PDataItemSL; @@ -428,7 +428,6 @@ begin Result := ItemSL; end; - (********************************************************************************************************************************) (********************************************************************************************************************************) (********************************************************************************************************************************) -- cgit v1.2.3