summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UCore.pas55
-rw-r--r--UCoreWorkers.pas49
2 files changed, 51 insertions, 53 deletions
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;
-
(********************************************************************************************************************************)
(********************************************************************************************************************************)
(********************************************************************************************************************************)
diff --git a/UCoreWorkers.pas b/UCoreWorkers.pas
index 2b5c4d5..cf0fc13 100644
--- a/UCoreWorkers.pas
+++ b/UCoreWorkers.pas
@@ -531,29 +531,25 @@ end;
procedure TWorkerThread.PrepareJobFilesFromPanel(AList: TList; DoNotRecurse: boolean);
var i: longint;
CurrPath: string;
- x: PDataItemSL;
+ InputFiles: TStringList;
begin
+ InputFiles := TStringList.Create;
CurrPath := IncludeTrailingPathDelimiter(Engine.Path);
+ // Process selected files first
if DataList.Count > 0 then
for i := 0 to DataList.Count - 1 do
with PDataItem(DataList[i])^ do
if (not UpDir) and Selected then
- if IsDir and (not IsLnk) and (not DoNotRecurse)
- then FillDirFiles(Engine, AList, CurrPath + String(FName))
- else begin
- x := GetFileInfoSL(Engine, CurrPath + String(FName));
- if x <> nil then AList.Add(x);
- end;
+ InputFiles.Add(CurrPath + String(FName));
+ // If not files are selected, take into the account current active item
if (AList.Count = 0) and Assigned(SelectedItem) and (not SelectedItem^.UpDir) then
- with SelectedItem^ do
- if IsDir and (not IsLnk) and (not DoNotRecurse)
- then FillDirFiles(Engine, AList, CurrPath + String(FName))
- else begin
- x := GetFileInfoSL(Engine, CurrPath + String(FName));
- if x <> nil then AList.Add(x);
- end;
+ InputFiles.Add(CurrPath + String(SelectedItem^.FName));
+
+ FillDirFiles(Engine, AList, InputFiles, DoNotRecurse);
+ InputFiles.Free;
end;
+
(********************************************************************************************************************************)
(********************************************************************************************************************************)
procedure ProcessProgressThread(SenderThread: TWorkerThread; ProgressForm: TFProgress);
@@ -767,7 +763,6 @@ var i: longint;
begin
SkipAll := False;
AList := TList.Create;
- AList.Clear;
with SenderThread do begin
CurrPath := IncludeTrailingPathDelimiter(Engine.Path);
PrepareJobFilesFromPanel(AList, False);
@@ -1274,19 +1269,19 @@ var DefResponse: integer; // Global variables for this function
end;
end;
+ // Can be called only once, otherwise sorting will fail and extract errors may appear
+ // TODO: make this universal
+ // TODO: this is complete mess, make it more clear
procedure HandleProcessPattern(AList: TList; CurrPath, FullPath, ParamFileName: string; ParamDir, Ren: boolean);
var s, s2: string;
b, CaseInsensitiveRename: boolean;
Info: PDataItemSL;
+ InputFiles: TStringList;
begin
- with SenderThread do
+ InputFiles := TStringList.Create;
+ with SenderThread do begin
if not Ren then begin
- if ParamDir then FillDirFiles(SrcEngine, AList, FullPath)
- else begin
- Info := GetFileInfoSL(SrcEngine, FullPath);
- if Info = nil then DebugMsg(['$$$ Copy: Something went wrong while building the filelist...'])
- else AList.Add(Info);
- end;
+ InputFiles.Add(FullPath);
end else begin
s := ProcessPattern(DestEngine, ParamString1, CurrPath, ParamFileName, ParamDir);
CaseInsensitiveRename := (WideCompareStr(ParamString1, ParamFileName) <> 0) and (WideCompareText(ParamString1, ParamFileName) = 0) and
@@ -1312,8 +1307,11 @@ var DefResponse: integer; // Global variables for this function
Info^.ForceMove := True;
AList.Add(Info);
end;
- end else FillDirFiles(SrcEngine, AList, FullPath);
+ end else InputFiles.Add(FullPath);
end;
+ FillDirFiles(SrcEngine, AList, InputFiles, False);
+ end;
+ InputFiles.Free;
end;
var i: longint;
@@ -1333,6 +1331,7 @@ begin
ParamString1 := ExcludeTrailingPathDelimiter(ParamString1);
if ParamString1 = '' then ParamString1 := PathDelim;
+ // Prepare list of files to copy
if ParamBool5 then begin // HandleVFSFromArchive
if not ExtractFromVFSAll then HandleProcessPattern(List, CurrPath, ParamString2, ExtractFileName(ParamString2), False, False)
else begin
@@ -1908,8 +1907,8 @@ var i: longint;
Fr: Single;
begin
SkipAll := False;
+ AList := TList.Create;
with SenderThread do begin
- AList := TList.Create;
PrepareJobFilesFromPanel(AList, not ParamBool1);
libc_chdir('/');
SetProgress1Params(AList.Count);
@@ -1986,8 +1985,8 @@ var i: longint;
Fr: Single;
begin
SkipAll := False;
+ AList := TList.Create;
with SenderThread do begin
- AList := TList.Create;
PrepareJobFilesFromPanel(AList, not ParamBool1);
libc_chdir('/');
SetProgress1Params(AList.Count);