diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-11-29 18:00:30 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-11-29 18:00:30 +0100 |
| commit | 7c2f3b3ab27e25834974eb656921a0fff4ef5377 (patch) | |
| tree | a450a51449041769776c3148ed851454e9a338d6 /UCore.pas | |
| parent | 959269c4432632e9228a5fa148eed2255e508554 (diff) | |
| download | tuxcmd-7c2f3b3ab27e25834974eb656921a0fff4ef5377.tar.xz | |
Transform FillDirFiles input to allow sorting
Diffstat (limited to 'UCore.pas')
| -rw-r--r-- | UCore.pas | 55 |
1 files changed, 27 insertions, 28 deletions
@@ -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; - (********************************************************************************************************************************) (********************************************************************************************************************************) (********************************************************************************************************************************) |
