mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Smart extract option (issue #3)
This commit is contained in:
parent
a03be982f8
commit
f0efd22342
4 changed files with 64 additions and 1 deletions
|
|
@ -131,6 +131,11 @@ begin
|
|||
end;
|
||||
|
||||
procedure TMultiArchiveCopyOutOperation.Initialize;
|
||||
var
|
||||
Index: Integer;
|
||||
ACount: Integer;
|
||||
AFileName: String;
|
||||
ArcFileList: TList;
|
||||
begin
|
||||
FExProcess:= TExProcess.Create(EmptyStr);
|
||||
FExProcess.OnReadLn:= @OnReadLn;
|
||||
|
|
@ -144,6 +149,30 @@ begin
|
|||
FExProcess.OnQueryString:= @OnQueryString;
|
||||
end;
|
||||
|
||||
if efSmartExtract in ExtractFlags then
|
||||
begin
|
||||
ACount:= 0;
|
||||
ArcFileList := FMultiArchiveFileSource.ArchiveFileList.Clone;
|
||||
try
|
||||
for Index := 0 to ArcFileList.Count - 1 do
|
||||
begin
|
||||
AFileName := PathDelim + TArchiveItem(ArcFileList[Index]).FileName;
|
||||
|
||||
if IsInPath(PathDelim, AFileName, False, False) then
|
||||
begin
|
||||
Inc(ACount);
|
||||
if (ACount > 1) then
|
||||
begin
|
||||
FTargetPath := FTargetPath + ExtractOnlyFileName(FMultiArchiveFileSource.ArchiveFileName) + PathDelim;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
ArcFileList.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
AddStateChangedListener([fsosStarting, fsosPausing, fsosStopping], @FileSourceOperationStateChangedNotify);
|
||||
|
||||
if FExtractMask = '' then FExtractMask := '*'; // extract all selected files/folders
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ uses
|
|||
uFile;
|
||||
|
||||
type
|
||||
TExtractFlag = (efSmartExtract);
|
||||
TExtractFlags = set of TExtractFlag;
|
||||
|
||||
{ TArchiveCopyInOperation }
|
||||
|
||||
|
|
@ -33,8 +35,10 @@ type
|
|||
TArchiveCopyOutOperation = class(TFileSourceCopyOutOperation)
|
||||
protected
|
||||
FExtractMask: String;
|
||||
FExtractFlags: TExtractFlags;
|
||||
public
|
||||
property ExtractMask: String read FExtractMask write FExtractMask;
|
||||
property ExtractFlags: TExtractFlags read FExtractFlags write FExtractFlags;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
|
|
|||
|
|
@ -45,10 +45,10 @@ type
|
|||
FSourceFileSource: IFileSource;
|
||||
FTargetFileSource: IFileSource;
|
||||
FSourceFiles: TFiles;
|
||||
FTargetPath: String;
|
||||
FRenameMask: String;
|
||||
|
||||
protected
|
||||
FTargetPath: String;
|
||||
FCopyAttributesOptions: TCopyAttributesOptions;
|
||||
FSymLinkOption: TFileSourceOperationOptionSymLink;
|
||||
FFileExistsOption: TFileSourceOperationOptionFileExists;
|
||||
|
|
|
|||
|
|
@ -209,6 +209,12 @@ begin
|
|||
end;
|
||||
|
||||
procedure TWcxArchiveCopyOutOperation.Initialize;
|
||||
var
|
||||
Index: Integer;
|
||||
ACount: Integer;
|
||||
AFileName: String;
|
||||
Header: TWcxHeader;
|
||||
ArcFileList: TList;
|
||||
begin
|
||||
// Is plugin allow multiple Operations?
|
||||
if FNeedsConnection then
|
||||
|
|
@ -221,6 +227,30 @@ begin
|
|||
FExtractWithoutPath := SourceFiles.Flat;
|
||||
end;
|
||||
|
||||
if efSmartExtract in ExtractFlags then
|
||||
begin
|
||||
ACount:= 0;
|
||||
ArcFileList := FWcxArchiveFileSource.ArchiveFileList.Clone;
|
||||
try
|
||||
for Index := 0 to ArcFileList.Count - 1 do
|
||||
begin
|
||||
AFileName := PathDelim + TWcxHeader(ArcFileList[Index]).FileName;
|
||||
|
||||
if IsInPath(PathDelim, AFileName, False, False) then
|
||||
begin
|
||||
Inc(ACount);
|
||||
if (ACount > 1) then
|
||||
begin
|
||||
FTargetPath := FTargetPath + ExtractOnlyFileName(FWcxArchiveFileSource.ArchiveFileName) + PathDelim;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
ArcFileList.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
// Check rename mask
|
||||
FRenamingFiles := (RenameMask <> '*.*') and (RenameMask <> '');
|
||||
if FRenamingFiles then SplitFileMask(RenameMask, FRenameNameMask, FRenameExtMask);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue