DEL: remove TTarWriter.ProcessTree() (TarBegin/TarFiles/TarEnd instead)

This commit is contained in:
rich2014 2026-06-19 14:59:59 +08:00
commit 64a37d0c69

View file

@ -127,8 +127,6 @@ type
);
destructor Destroy; override;
function ProcessTree(var Files: TFiles; var Statistics: TFileSourceCopyOperationStatistics): Boolean;
function TarBegin: Boolean;
function TarFiles(const Files: TFiles; var Statistics: TFileSourceCopyOperationStatistics): Boolean;
function TarEnd(const beforeResult: Boolean): Boolean;
@ -702,95 +700,6 @@ begin
end;
end;
function TTarWriter.ProcessTree(var Files: TFiles;
var Statistics: TFileSourceCopyOperationStatistics): Boolean;
var
aFile: TFile;
Divider: Int64 = 1;
CurrentFileIndex: Integer;
iTotalDiskSize, iFreeDiskSize: Int64;
begin
try
Result:= False;
// Set base path
FBasePath:= Files.Path;
if FMemPack = 0 then begin
Divider:= 2;
end;
// Update progress
with Statistics do
begin
CurrentFileTo:= FArchiveFileName;
TotalBytes:= TotalBytes * Divider;
UpdateStatistics(Statistics);
end;
// Check disk free space
//if FCheckFreeSpace = True then
begin
GetDiskFreeSpace(FTargetPath, iFreeDiskSize, iTotalDiskSize);
if Statistics.TotalBytes > iFreeDiskSize then
begin
AskQuestion('', rsMsgNoFreeSpaceCont, [fsourAbort], fsourAbort, fsourAbort);
AbortOperation;
end;
end;
// Create destination file
FTargetStream := TFileStreamEx.Create(FArchiveFileName, fmCreate);
try
for CurrentFileIndex := 0 to Files.Count - 1 do
begin
aFile := Files[CurrentFileIndex];
if aFile.IsDirectory or aFile.IsLink then
begin
// Add file record only
AddFile(aFile.FullPath);
end
else
begin
// Update progress
with Statistics do
begin
CurrentFileFrom := aFile.FullPath;
CurrentFileTotalBytes := aFile.Size;
CurrentFileDoneBytes := 0;
end;
UpdateStatistics(Statistics);
// Add file record
AddFile(aFile.FullPath);
// TAR current file
if not WriteFile(aFile.FullPath, Statistics) then Break;
end;
CheckOperationState;
end;
// Finish TAR archive with two null records
FillByte(FBufferIn^, RECORDSIZE * 2, 0);
DataWrite(FBufferIn, RECORDSIZE * 2);
// Finish compression if needed
if (FMemPack <> 0) then CompressData(FBufferIn, 0);
finally
if Assigned(FTargetStream) then
begin
FreeAndNil(FTargetStream);
if (Statistics.DoneBytes <> Statistics.TotalBytes div Divider) then
// There was some error, because not all files has been archived.
// Delete the not completed target file.
mbDeleteFile(FArchiveFileName)
else
Result:= True;
end;
end;
except
on EFCreateError do
begin
ShowError(rsMsgLogError + rsMsgErrECreate + ': ' + FArchiveFileName);
end;
end;
end;
function TTarWriter.TarBegin: Boolean;
begin
Result:= False;