FIX: Interrupt list operations when they are aborted.

This commit is contained in:
cobines 2012-05-12 15:55:40 +00:00
commit 614447111e
8 changed files with 51 additions and 36 deletions

View file

@ -33,40 +33,44 @@ procedure TFileSystemListOperation.MainExecute;
var
AFile: TFile;
sr: TSearchRecEx;
IsRootPath: Boolean;
IsRootPath, Found: Boolean;
begin
FFiles.Clear;
IsRootPath := FileSource.IsPathAtRoot(Path);
if FindFirstEx(FFiles.Path + '*', faAnyFile, sr) <> 0 then
begin
{ No files have been found. }
FindCloseEx(sr);
if not IsRootPath then
Found := FindFirstEx(FFiles.Path + '*', faAnyFile, sr) = 0;
try
if not Found then
begin
AFile := TFileSystemFileSource.CreateFile(Path);
AFile.Name := '..';
AFile.Attributes := faFolder;
FFiles.Add(AFile);
{ No files have been found. }
if not IsRootPath then
begin
AFile := TFileSystemFileSource.CreateFile(Path);
AFile.Name := '..';
AFile.Attributes := faFolder;
FFiles.Add(AFile);
end;
end
else
begin
repeat
CheckOperationState;
if sr.Name='.' then Continue;
// Don't include '..' in the root directory.
if (sr.Name='..') and IsRootPath then
Continue;
AFile := TFileSystemFileSource.CreateFile(Path, @sr);
FFiles.Add(AFile);
until FindNextEx(sr)<>0;
end;
Exit;
finally
FindCloseEx(sr);
end;
repeat
if sr.Name='.' then Continue;
// Don't include '..' in the root directory.
if (sr.Name='..') and IsRootPath then
Continue;
AFile := TFileSystemFileSource.CreateFile(Path, @sr);
FFiles.Add(AFile);
until FindNextEx(sr)<>0;
FindCloseEx(sr);
end;
end.

View file

@ -52,13 +52,15 @@ begin
ArcFileList := FMultiArchiveFileSource.ArchiveFileList;
for I := 0 to ArcFileList.Count - 1 do
begin
CheckOperationState;
CurrFileName := PathDelim + TArchiveItem(ArcFileList.Items[I]).FileName;
if not IsInPath(Path, CurrFileName, False, False) then
Continue;
with FMultiArchiveFileSource.MultiArcItem do
aFile := TMultiArchiveFileSource.CreateFile(Path, TArchiveItem(ArcFileList.Items[I]), FFormMode);
aFile := TMultiArchiveFileSource.CreateFile(Path, TArchiveItem(ArcFileList.Items[I]), FFormMode);
FFiles.Add(AFile);
end;
end;

View file

@ -50,6 +50,7 @@ begin
// Search for files in the given path.
while (Path <> CurrentPath) and IsInPath(CurrentPath, Path, True, False) do
begin
CheckOperationState;
Found := False;
for i := 0 to CurrentNode.SubNodesCount - 1 do
begin
@ -79,6 +80,7 @@ begin
begin
for i := 0 to CurrentNode.SubNodesCount - 1 do
begin
CheckOperationState;
AFile := CurrentNode.SubNodes[i].TheFile;
FFiles.Add(AFile);
end;

View file

@ -41,6 +41,7 @@ procedure TSearchResultListOperation.MainExecute;
begin
for i := 0 to aNode.SubNodesCount - 1 do
begin
CheckOperationState;
FFiles.Add(aNode.SubNodes[i].TheFile.Clone);
AddNode(aNode.SubNodes[i]);
end;

View file

@ -42,6 +42,7 @@ begin
with FVfsFileSource do
for I := 0 to VfsFileList.Count - 1 do
begin
CheckOperationState;
aFile := TVfsFileSource.CreateFile(Path);
aFile.Name:= VfsFileList.Name[I];
//aFile.ModificationTime:= FileDateToDateTime(mbFileAge(VfsFileList.FileName[I]));
@ -49,6 +50,7 @@ begin
end;
for I:= 0 to gVfsModuleList.Count - 1 do
begin
CheckOperationState;
aFile := TVfsFileSource.CreateFile(Path);
aFile.Name:= gVfsModuleList.Strings[I];
//aFile.ModificationTime:= FileDateToDateTime(mbFileAge(VfsFileList.FileName[I]));

View file

@ -52,6 +52,7 @@ begin
ArcFileList := FWcxArchiveFileSource.ArchiveFileList;
for I := 0 to ArcFileList.Count - 1 do
begin
CheckOperationState;
CurrFileName := PathDelim + TWCXHeader(ArcFileList.Items[I]).FileName;
if not IsInPath(Path, CurrFileName, False, False) then

View file

@ -86,16 +86,18 @@ begin
end;
Handle := WfxFindFirst(FCurrentPath, FindData);
if Handle = wfxInvalidHandle then Exit;
repeat
if (FindData.FileName = '.') or (FindData.FileName = '..') then Continue;
aFile := TWfxPluginFileSource.CreateFile(Path, FindData);
FFiles.Add(aFile);
until (not WfxFindNext(Handle, FindData));
FsFindClose(Handle);
if Handle <> wfxInvalidHandle then
try
repeat
CheckOperationState;
if (FindData.FileName = '.') or (FindData.FileName = '..') then Continue;
aFile := TWfxPluginFileSource.CreateFile(Path, FindData);
FFiles.Add(aFile);
until (not WfxFindNext(Handle, FindData));
finally
FsFindClose(Handle);
end;
end; // with
end;

View file

@ -89,6 +89,7 @@ begin
nFileList:= PNetResourceArray(lpBuffer);
for I := 0 to dwCount - 1 do
begin
CheckOperationState;
aFile := TWinNetFileSource.CreateFile(Path);
aFile.FullPath:= UTF8Encode(WideString(nFileList^.lpRemoteName));
aFile.CommentProperty.Value:= UTF8Encode(WideString(nFileList^.lpComment));