UPD: Restore "Extract all and execute"

This commit is contained in:
Alexander Koblov 2010-07-13 09:34:28 +00:00
commit 030987f75d
4 changed files with 30 additions and 13 deletions

View file

@ -50,7 +50,7 @@ type
destructor Destroy; override;
end;
function ShowFileExecuteYourSelf(aFileView: TFileView; aFile: TFile): Boolean;
function ShowFileExecuteYourSelf(aFileView: TFileView; aFile: TFile; bWithAll: Boolean): Boolean;
implementation
@ -59,20 +59,30 @@ implementation
uses
LCLProc, uTempFileSystemFileSource, uFileSourceOperation, uShellExecute, uOSUtils;
function ShowFileExecuteYourSelf(aFileView: TFileView; aFile: TFile): Boolean;
function ShowFileExecuteYourSelf(aFileView: TFileView; aFile: TFile; bWithAll: Boolean): Boolean;
var
ActiveFile: TFile = nil;
TempFiles: TFiles = nil;
TempFileSource: ITempFileSystemFileSource = nil;
Operation: TFileSourceOperation = nil;
CurrentDir: UTF8String;
CurrentDir,
FileName: UTF8String;
begin
Result:= False;
try
ActiveFile:= aFile.Clone;
TempFiles:= TFiles.Create(aFileView.CurrentPath);
TempFiles.Add(aFile.Clone);
TempFileSource:= TTempFileSystemFileSource.GetFileSource;
if bWithAll then
begin
FileName:= TempFileSource.FileSystemRoot + aFile.FullPath;
TempFiles:= aFileView.FileSource.GetFiles(aFileView.FileSource.GetRootDir);
end
else
begin
FileName:= TempFileSource.FileSystemRoot + aFile.Name;
TempFiles:= TFiles.Create(aFileView.CurrentPath);
TempFiles.Add(aFile.Clone);
end;
Operation := aFileView.FileSource.CreateCopyOutOperation(
TempFileSource,
TempFiles,
@ -84,7 +94,7 @@ begin
FreeAndNil(Operation);
CurrentDir:= mbGetCurrentDir;
Result:= ShellExecuteEx('open', TempFileSource.FileSystemRoot + aFile.Name, TempFileSource.FileSystemRoot + aFile.Path);
Result:= ShellExecuteEx('open', FileName, TempFileSource.FileSystemRoot + aFile.Path);
mbSetCurrentDir(CurrentDir);
if Result then
begin

View file

@ -85,7 +85,7 @@ begin
mrOK:
Result:= fseorYourSelf;
mrAll:
Result:= fseorYourSelf;
Result:= fseorWithAll;
end;
Free;
end;

View file

@ -14,10 +14,11 @@ uses
type
TFileSourceExecuteOperationResult =
(fseorSuccess, //<en the command was executed successfully
fseorError, //<en execution failed
fseorYourSelf, //<en DC should download the file and execute it locally
fseorSymLink); //<en this was a (symbolic) link or .lnk file pointing to a different directory
(fseorSuccess, //<en the command was executed successfully
fseorError, //<en execution failed
fseorYourSelf, //<en DC should download/extract the file and execute it locally
fseorWithAll, //<en DC should download/extract all files and execute chosen file locally
fseorSymLink); //<en this was a (symbolic) link or .lnk file pointing to a different directory
{ TFileSourceExecuteOperation }

View file

@ -94,8 +94,14 @@ begin
DebugLn('Execution error!');
fseorYourSelf:
begin
// CopyOut file to temp file system and execute
if not ShowFileExecuteYourSelf(aFileView, aFile) then
// Copy out file to temp file system and execute
if not ShowFileExecuteYourSelf(aFileView, aFile, False) then
DebugLn('Execution error!');
end;
fseorWithAll:
begin
// Copy out all files to temp file system and execute chosen
if not ShowFileExecuteYourSelf(aFileView, aFile, True) then
DebugLn('Execution error!');
end;
fseorSymLink: