mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: apply fsoPack/TFileSourceProcessor in cm_PackFiles() to support various FileSources
This commit is contained in:
parent
be807fdb54
commit
fda9362805
2 changed files with 60 additions and 55 deletions
|
|
@ -26,9 +26,10 @@ unit fPackDlg;
|
|||
interface
|
||||
|
||||
uses
|
||||
SysUtils, Forms, Controls, Dialogs, StdCtrls, EditBtn, ExtCtrls, Buttons,
|
||||
Menus, DividerBevel, uWcxArchiveFileSource, uArchiveFileSource, uFile,
|
||||
uFileSource, Classes, fButtonForm, uFileSourceOperation;
|
||||
SysUtils, Classes, Forms, Controls, Dialogs, StdCtrls, EditBtn, ExtCtrls,
|
||||
Buttons, Menus, DividerBevel, fButtonForm,
|
||||
uWcxArchiveFileSource, uArchiveFileSource, uFile,
|
||||
uFileSource, uFileSourceManager, uFileSourceOperation;
|
||||
|
||||
type
|
||||
|
||||
|
|
@ -86,12 +87,9 @@ type
|
|||
end;
|
||||
|
||||
// Frees 'Files'.
|
||||
procedure ShowPackDlg(TheOwner: TComponent;
|
||||
const SourceFileSource: IFileSource;
|
||||
const TargetFileSource: IFileSource;
|
||||
var Files: TFiles;
|
||||
TargetArchivePath: String;
|
||||
TargetPathInArchive: String);
|
||||
procedure ShowPackDlg(const TheOwner: TComponent;
|
||||
var params: TFileSourceConsultParams;
|
||||
const TargetPathInArchive: String);
|
||||
|
||||
implementation
|
||||
|
||||
|
|
@ -104,15 +102,13 @@ uses
|
|||
DCStrUtils, uMultiArc, uWcxModule, uTempFileSystemFileSource,
|
||||
uFileSourceCopyOperation, uShowForm, uShowMsg, uGlobsPaths;
|
||||
|
||||
procedure ShowPackDlg(TheOwner: TComponent;
|
||||
const SourceFileSource: IFileSource;
|
||||
const TargetFileSource: IFileSource;
|
||||
var Files: TFiles;
|
||||
TargetArchivePath: String;
|
||||
TargetPathInArchive: String);
|
||||
procedure ShowPackDlg(const TheOwner: TComponent;
|
||||
var params: TFileSourceConsultParams;
|
||||
const TargetPathInArchive: String);
|
||||
var
|
||||
I: Integer;
|
||||
PackDialog: TfrmPackDlg;
|
||||
f: TFile;
|
||||
begin
|
||||
PackDialog := TfrmPackDlg.Create(TheOwner);
|
||||
{$IF DEFINED(LCLGTK2)}
|
||||
|
|
@ -123,46 +119,48 @@ begin
|
|||
{$ENDIF}
|
||||
with PackDialog do
|
||||
try
|
||||
FCount:= Files.Count;
|
||||
FCount:= params.files.Count;
|
||||
FArchiveType:= 'none';
|
||||
FSourceFileSource:= SourceFileSource;
|
||||
FTargetFileSource:= TargetFileSource;
|
||||
FSourceFileSource:= params.sourceFS;
|
||||
FTargetFileSource:= params.targetFS;
|
||||
FTargetPathInArchive:= TargetPathInArchive;
|
||||
FArchiveExt:= ExtensionSeparator + FArchiveType;
|
||||
|
||||
if Files.Count = 1 then // if one file selected
|
||||
if params.files.Count = 1 then // if one file selected
|
||||
begin
|
||||
FArchiveName:= Files[0].NameNoExt;
|
||||
FHasFolder:= Files[0].IsDirectory or Files[0].IsLinkToDirectory;
|
||||
edtPackCmd.Text := TargetArchivePath + FArchiveName + ExtensionSeparator + FArchiveType;
|
||||
f:= params.files[0];
|
||||
FArchiveName:= ExtractOnlyFileName( params.sourceFS.GetFileName(f) );
|
||||
FHasFolder:= f.IsDirectory or f.IsLinkToDirectory;
|
||||
edtPackCmd.Text := params.targetPath + FArchiveName + ExtensionSeparator + FArchiveType;
|
||||
end
|
||||
else // if some files selected
|
||||
begin
|
||||
FHasFolder:= False;
|
||||
for I:= 0 to Files.Count - 1 do
|
||||
for I:= 0 to params.files.Count - 1 do
|
||||
begin
|
||||
if Files[I].IsDirectory or Files[I].IsLinkToDirectory then
|
||||
f:= params.files[I];
|
||||
if f.IsDirectory or f.IsLinkToDirectory then
|
||||
begin
|
||||
FHasFolder:= True;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
FArchiveName:= MakeFileName(Files.Path, 'archive');
|
||||
edtPackCmd.Text := TargetArchivePath + FArchiveName + ExtensionSeparator + FArchiveType;
|
||||
FArchiveName:= MakeFileName(params.files.Path, 'archive');
|
||||
edtPackCmd.Text := params.targetPath + FArchiveName + ExtensionSeparator + FArchiveType;
|
||||
end;
|
||||
|
||||
if (ShowModal = mrOK) then
|
||||
begin
|
||||
case PrepareData(SourceFileSource, Files, @OnPackCopyOutStateChanged) of
|
||||
FileSourceManager.confirmOperation( params );
|
||||
case PrepareData(params.sourceFS, params.files, @OnPackCopyOutStateChanged) of
|
||||
pdrInCallback:
|
||||
PackDialog:= nil;
|
||||
pdrSynchronous:
|
||||
PackFiles(SourceFileSource, Files);
|
||||
PackFiles(params.sourceFS, params.files);
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
FreeAndNil(PackDialog);
|
||||
FreeAndNil(Files);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ uses fOptionsPluginsBase, fOptionsPluginsDSX, fOptionsPluginsWCX,
|
|||
fLinker, fSplitter, fDescrEdit, fCheckSumVerify, fCheckSumCalc, fSetFileProperties,
|
||||
uLng, uLog, uShowMsg, uOSForms, uOSUtils, uDCUtils, uBriefFileView, fSelectDuplicates,
|
||||
uShowForm, uShellExecute, uClipboard, uHash, uDisplayFile, uLuaPas, uSysFolders,
|
||||
uFilePanelSelect, uFileSystemFileSource, uQuickViewPanel, Math, fViewer,
|
||||
uFilePanelSelect, uFileSourceManager, uFileSystemFileSource, uQuickViewPanel, Math, fViewer,
|
||||
uOperationsManager, uFileSourceOperationTypes, uWfxPluginFileSource,
|
||||
uFileSystemDeleteOperation, uFileSourceExecuteOperation, uSearchResultFileSource,
|
||||
uFileSourceOperationMessageBoxesUI, uFileSourceCalcChecksumOperation,
|
||||
|
|
@ -1483,41 +1483,48 @@ end;
|
|||
procedure TMainCommands.cm_PackFiles(const Params: array of string);
|
||||
var
|
||||
Param: String;
|
||||
TargetPath: String;
|
||||
SelectedFiles: TFiles;
|
||||
TargetFileSource: IFileSource;
|
||||
fsParams: TFileSourceConsultParams;
|
||||
begin
|
||||
with frmMain do
|
||||
begin
|
||||
fsParams:= Default(TFileSourceConsultParams);
|
||||
fsParams.operationType:= fsoPack;
|
||||
fsParams.sourceFS:= ActiveFrame.FileSource;
|
||||
|
||||
Param := GetDefaultParam(Params);
|
||||
if Param = 'PackHere' then
|
||||
begin
|
||||
TargetPath:= ActiveFrame.CurrentPath;
|
||||
TargetFileSource:= ActiveFrame.FileSource;
|
||||
fsParams.targetPath:= ActiveFrame.CurrentPath;
|
||||
fsParams.targetFS:= ActiveFrame.FileSource;
|
||||
end
|
||||
else begin
|
||||
TargetPath:= NotActiveFrame.CurrentPath;
|
||||
TargetFileSource:= NotActiveFrame.FileSource;
|
||||
fsParams.targetPath:= NotActiveFrame.CurrentPath;
|
||||
fsParams.targetFS:= NotActiveFrame.FileSource;
|
||||
end;
|
||||
if not (fspDirectAccess in TargetFileSource.Properties) then
|
||||
msgError(rsMsgErrNotSupported)
|
||||
else begin
|
||||
SelectedFiles := ActiveFrame.CloneSelectedOrActiveFiles;
|
||||
try
|
||||
if SelectedFiles.Count = 0 then
|
||||
msgWarning(rsMsgNoFilesSelected)
|
||||
else begin
|
||||
ShowPackDlg(frmMain,
|
||||
ActiveFrame.FileSource,
|
||||
TargetFileSource,
|
||||
SelectedFiles,
|
||||
TargetPath,
|
||||
PathDelim { Copy to root of archive } {NotActiveFrame.FileSource.GetRootString}
|
||||
);
|
||||
end;
|
||||
finally
|
||||
FreeAndNil(SelectedFiles);
|
||||
|
||||
fsParams.files:= ActiveFrame.CloneSelectedOrActiveFiles;
|
||||
try
|
||||
if fsParams.files.Count = 0 then begin
|
||||
msgWarning(rsMsgNoFilesSelected);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
FileSourceManager.consultOperation( fsParams );
|
||||
case fsParams.consultResult of
|
||||
fscrNotSupported:
|
||||
msgError(rsMsgErrNotSupported);
|
||||
fscrNotImplemented:
|
||||
msgError(rsMsgNotImplemented);
|
||||
end;
|
||||
if fsParams.consultResult <> fscrSuccess then
|
||||
Exit;
|
||||
|
||||
ShowPackDlg(frmMain,
|
||||
fsParams,
|
||||
PathDelim { Copy to root of archive } {NotActiveFrame.FileSource.GetRootString}
|
||||
);
|
||||
finally
|
||||
FreeAndNil(fsParams.files);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue