summaryrefslogtreecommitdiff
path: root/UCore.pas
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2024-10-23 20:00:31 +0200
committerTomas Bzatek <tbzatek@redhat.com>2024-10-23 20:01:41 +0200
commita4bb8f8172e8d1f0ac69a09f0f3d61e82fca02c0 (patch)
tree635f571fbc320992f4abc8f9cd9543e079349536 /UCore.pas
parent7d757b8452daed2575e3a9cc300459d7e8674345 (diff)
downloadtuxcmd-a4bb8f8172e8d1f0ac69a09f0f3d61e82fca02c0.tar.xz
FillDirFiles: Ditch the SortForStream argument
Always passed True, unused.
Diffstat (limited to 'UCore.pas')
-rw-r--r--UCore.pas75
1 files changed, 30 insertions, 45 deletions
diff --git a/UCore.pas b/UCore.pas
index ed89fd0..7f4f8b6 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; DestList: TList; InputFiles: TStringList; DoNotRecurse, SortForStream: boolean; InaccessiblePaths: TStringList; CancelFlag: Pboolean);
+procedure FillDirFiles(Engine: TPanelEngine; DestList: TList; InputFiles: TStringList; DoNotRecurse: boolean; InaccessiblePaths: TStringList; CancelFlag: Pboolean);
function GetFileInfoSL(Engine: TPanelEngine; const APath: string): PDataItemSL;
procedure DebugWriteListSL(List: TList);
@@ -348,19 +348,14 @@ end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
-procedure FillDirFiles(Engine: TPanelEngine; DestList: TList; InputFiles: TStringList; DoNotRecurse, SortForStream: boolean; InaccessiblePaths: TStringList; CancelFlag: Pboolean);
+procedure FillDirFiles(Engine: TPanelEngine; DestList: TList; InputFiles: TStringList; DoNotRecurse: boolean; InaccessiblePaths: TStringList; CancelFlag: Pboolean);
var DirStage1List, FilesList, DirStage2List: TList;
function FillDirFiles_compare_func(Item1, Item2: Pointer): integer;
var DataItem1, DataItem2: PDataItem;
begin
- if not SortForStream then begin
- DataItem1 := Item1;
- DataItem2 := Item2;
- end else begin
- DataItem1 := PDataItemSL(Item1)^.DataItem;
- DataItem2 := PDataItemSL(Item2)^.DataItem;
- end;
+ DataItem1 := PDataItemSL(Item1)^.DataItem;
+ DataItem2 := PDataItemSL(Item2)^.DataItem;
// sort by inode number
// also, we want to have directories at the bottom of the list
if DataItem1^.IsDir and (not DataItem2^.IsDir) then Result := 1 else
@@ -401,13 +396,13 @@ var DirStage1List, FilesList, DirStage2List: TList;
var i: integer;
begin
if FList.Count < 2 then Exit;
- writeln('before sorting:');
+ DebugMsg(['before sorting:']);
for i := 0 to FList.Count - 1 do
- writeln(' ', i, ' [', PDataItemSL(FList[i])^.DataItem^.inode_no, '] ', PDataItemSL(FList[i])^.DataItem^.FName);
+ DebugMsg([' ', i, ' [', PDataItemSL(FList[i])^.DataItem^.inode_no, '] ', PDataItemSL(FList[i])^.DataItem^.FName]);
QuickSort(Flist, 0, FList.Count - 1);
- writeln('after sorting:');
+ DebugMsg(['after sorting:']);
for i := 0 to FList.Count - 1 do
- writeln(' ', i, ' [', PDataItemSL(FList[i])^.DataItem^.inode_no, '] ', PDataItemSL(FList[i])^.DataItem^.FName);
+ DebugMsg([' ', i, ' [', PDataItemSL(FList[i])^.DataItem^.inode_no, '] ', PDataItemSL(FList[i])^.DataItem^.FName]);
end;
procedure FillDirFiles_Recurse(const LocalPath: string; ALevel: integer);
@@ -422,7 +417,6 @@ var DirStage1List, FilesList, DirStage2List: TList;
LocalList := TList.Create;
Error := nil;
if Engine.GetListing(LocalList, LocalPath, True, False, True, @Error) then begin
- if not SortForStream then FillDirFiles_sort(LocalList);
for i := 0 to LocalList.Count - 1 do begin
Item := LocalList[i];
ItemSL := malloc(sizeof(TDataItemSL));
@@ -431,10 +425,8 @@ var DirStage1List, FilesList, DirStage2List: TList;
ItemSL^.Stage1 := True;
ItemSL^.IsOnRO := Engine.IsOnROMedium(string(Item^.FName));
ItemSL^.Level := ALevel;
- if not SortForStream then DestList.Add(ItemSL) else begin
- if Item^.IsDir then DirStage1List.Add(ItemSL)
- else FilesList.Add(ItemSL);
- end;
+ if Item^.IsDir then DirStage1List.Add(ItemSL)
+ else FilesList.Add(ItemSL);
if Item^.IsDir then begin
// Recurse to parent
@@ -450,8 +442,7 @@ var DirStage1List, FilesList, DirStage2List: TList;
// Add end stage
ItemSL := DuplicateDataItem(ItemSL);
ItemSL^.Stage1 := False;
- if SortForStream then DirStage2List.Add(ItemSL)
- else DestList.Add(ItemSL);
+ DirStage2List.Add(ItemSL)
end;
end;
end else begin
@@ -469,11 +460,9 @@ var root: PDataItemSL;
i: integer;
begin
if InputFiles.Count = 0 then Exit;
- if SortForStream then begin
- DirStage1List := TList.Create;
- FilesList := TList.Create;
- DirStage2List := TList.Create;
- end;
+ DirStage1List := TList.Create;
+ FilesList := TList.Create;
+ DirStage2List := TList.Create;
for i := 0 to InputFiles.Count - 1 do begin
root := GetFileInfoSL(Engine, InputFiles[i]);
@@ -484,39 +473,35 @@ begin
end;
root^.Stage1 := True;
root^.Level := 1;
- if not SortForStream then DestList.Add(root) else
if not root^.DataItem^.IsDir then FilesList.Add(root);
if root^.DataItem^.IsDir then begin
// It's a directory, mark as starting item
- if SortForStream then DirStage1List.Add(root);
+ DirStage1List.Add(root);
// Recurse to child
FillDirFiles_Recurse(InputFiles[i], 2);
// Add ending item
root := GetFileInfoSL(Engine, InputFiles[i]);
root^.Stage1 := False;
root^.Level := 1;
- if SortForStream then DirStage2List.Add(root)
- else DestList.Add(root);
+ DirStage2List.Add(root);
end;
end;
// Merge lists
- if SortForStream then begin
- FillDirFiles_sort(FilesList);
- if DirStage1List.Count > 0 then
- for i := 0 to DirStage1List.Count - 1 do
- DestList.Add(DirStage1List[i]);
- if FilesList.Count > 0 then
- for i := 0 to FilesList.Count - 1 do
- DestList.Add(FilesList[i]);
- if DirStage2List.Count > 0 then
- for i := 0 to DirStage2List.Count - 1 do
- DestList.Add(DirStage2List[i]);
- DirStage1List.Free;
- FilesList.Free;
- DirStage2List.Free;
- end;
+ FillDirFiles_sort(FilesList);
+ if DirStage1List.Count > 0 then
+ for i := 0 to DirStage1List.Count - 1 do
+ DestList.Add(DirStage1List[i]);
+ if FilesList.Count > 0 then
+ for i := 0 to FilesList.Count - 1 do
+ DestList.Add(FilesList[i]);
+ if DirStage2List.Count > 0 then
+ for i := 0 to DirStage2List.Count - 1 do
+ DestList.Add(DirStage2List[i]);
+ DirStage1List.Free;
+ FilesList.Free;
+ DirStage2List.Free;
end;
function GetFileInfoSL(Engine: TPanelEngine; const APath: string): PDataItemSL;
@@ -554,7 +539,7 @@ begin
for i := 0 to List.Count - 1 do
if not Assigned(List[i]) then WriteLn('**** List Item idx ', i, '; base @ nil') else
try
- WriteLn('**** List Item idx ', i, '; base @ ', integer(List[i]), '; sizeof = ', SizeOf(List[i]));
+ WriteLn('**** List Item idx ', i);
Item := List[i];
WriteLn(' Stage1: ', Item^.Stage1, ', Level: ', Item^.Level, ', IsDir: ', Item^.DataItem^.IsDir, ', IsLnk: ', Item^.DataItem^.IsLnk, ', ForceMove: ', Item^.ForceMove{, ', Size: ', Item^.DataItem^.Size}, ', inode: ', Item^.DataItem^.inode_no);
WriteLn(' FName: ', Item^.DataItem^.FName);