|
@@ -15,18 +15,21 @@ interface
|
|
type
|
|
type
|
|
TOnExtractionProgress = function(const ArchiveName, FileName: string; const Progress, ProgressMax: Int64): Boolean of object;
|
|
TOnExtractionProgress = function(const ArchiveName, FileName: string; const Progress, ProgressMax: Int64): Boolean of object;
|
|
|
|
|
|
-procedure Extract7ZipArchive(const ArchiveFileName, DestDir: String;
|
|
|
|
- const FullPaths: Boolean; const OnExtractionProgress: TOnExtractionProgress);
|
|
|
|
|
|
+procedure Extract7ZipArchiveRedir(const DisableFsRedir: Boolean;
|
|
|
|
+ const ArchiveFileName, DestDir: String; const FullPaths: Boolean;
|
|
|
|
+ const OnExtractionProgress: TOnExtractionProgress);
|
|
|
|
|
|
implementation
|
|
implementation
|
|
|
|
|
|
uses
|
|
uses
|
|
Windows, SysUtils, Forms,
|
|
Windows, SysUtils, Forms,
|
|
PathFunc,
|
|
PathFunc,
|
|
- Shared.SetupMessageIDs, SetupLdrAndSetup.Messages, Setup.LoggingFunc, Setup.MainFunc, Setup.InstFunc;
|
|
|
|
|
|
+ Shared.SetupMessageIDs, SetupLdrAndSetup.Messages, SetupLdrAndSetup.RedirFunc,
|
|
|
|
+ Setup.LoggingFunc, Setup.MainFunc, Setup.InstFunc;
|
|
|
|
|
|
type
|
|
type
|
|
TSevenZipDecodeState = record
|
|
TSevenZipDecodeState = record
|
|
|
|
+ DisableFsRedir: Boolean;
|
|
ExpandedArchiveFileName, ExpandedDestDir: String;
|
|
ExpandedArchiveFileName, ExpandedDestDir: String;
|
|
LogBuffer: AnsiString;
|
|
LogBuffer: AnsiString;
|
|
ExtractedArchiveName: String;
|
|
ExtractedArchiveName: String;
|
|
@@ -51,7 +54,7 @@ function __CreateDirectoryW(lpPathName: LPCWSTR;
|
|
begin
|
|
begin
|
|
var ExpandedDir: String;
|
|
var ExpandedDir: String;
|
|
if ValidateAndCombinePath(State.ExpandedDestDir, lpPathName, ExpandedDir) then
|
|
if ValidateAndCombinePath(State.ExpandedDestDir, lpPathName, ExpandedDir) then
|
|
- Result := CreateDirectoryW(PChar(ExpandedDir), lpSecurityAttributes)
|
|
|
|
|
|
+ Result := CreateDirectoryRedir(State.DisableFsRedir, ExpandedDir, lpSecurityAttributes)
|
|
else begin
|
|
else begin
|
|
Result := False;
|
|
Result := False;
|
|
SetLastError(ERROR_ACCESS_DENIED);
|
|
SetLastError(ERROR_ACCESS_DENIED);
|
|
@@ -82,7 +85,9 @@ begin
|
|
(PathCompare(ExpandedFileName, State.ExpandedArchiveFileName) = 0)) or
|
|
(PathCompare(ExpandedFileName, State.ExpandedArchiveFileName) = 0)) or
|
|
((dwDesiredAccess = GENERIC_WRITE) and
|
|
((dwDesiredAccess = GENERIC_WRITE) and
|
|
ValidateAndCombinePath(State.ExpandedDestDir, lpFileName, ExpandedFileName)) then
|
|
ValidateAndCombinePath(State.ExpandedDestDir, lpFileName, ExpandedFileName)) then
|
|
- Result := CreateFileW(PChar(ExpandedFileName), dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile)
|
|
|
|
|
|
+ Result := CreateFileRedir(State.DisableFsRedir, ExpandedFileName,
|
|
|
|
+ dwDesiredAccess, dwShareMode, lpSecurityAttributes,
|
|
|
|
+ dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile)
|
|
else begin
|
|
else begin
|
|
Result := INVALID_HANDLE_VALUE;
|
|
Result := INVALID_HANDLE_VALUE;
|
|
SetLastError(ERROR_ACCESS_DENIED);
|
|
SetLastError(ERROR_ACCESS_DENIED);
|
|
@@ -110,7 +115,7 @@ end;
|
|
|
|
|
|
function __SetFileAttributesW(lpFileName: LPCWSTR; dwFileAttributes: DWORD): BOOL; cdecl;
|
|
function __SetFileAttributesW(lpFileName: LPCWSTR; dwFileAttributes: DWORD): BOOL; cdecl;
|
|
begin
|
|
begin
|
|
- Result := SetFileAttributesW(lpFileName, dwFileAttributes);
|
|
|
|
|
|
+ Result := SetFileAttributesRedir(State.DisableFsRedir, lpFileName, dwFileAttributes);
|
|
end;
|
|
end;
|
|
|
|
|
|
function __SetFilePointer(hFile: THandle; lDistanceToMove: Longint;
|
|
function __SetFilePointer(hFile: THandle; lDistanceToMove: Longint;
|
|
@@ -266,8 +271,9 @@ begin
|
|
State.Aborted := True;
|
|
State.Aborted := True;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure Extract7ZipArchive(const ArchiveFileName, DestDir: String;
|
|
|
|
- const FullPaths: Boolean; const OnExtractionProgress: TOnExtractionProgress);
|
|
|
|
|
|
+procedure Extract7ZipArchiveRedir(const DisableFsRedir: Boolean;
|
|
|
|
+ const ArchiveFileName, DestDir: String; const FullPaths: Boolean;
|
|
|
|
+ const OnExtractionProgress: TOnExtractionProgress);
|
|
begin
|
|
begin
|
|
if ArchiveFileName = '' then
|
|
if ArchiveFileName = '' then
|
|
InternalError('Extract7ZipArchive: Invalid ArchiveFileName value');
|
|
InternalError('Extract7ZipArchive: Invalid ArchiveFileName value');
|
|
@@ -280,6 +286,7 @@ begin
|
|
if not ForceDirectoriesRedir(False, DestDir) or not SetCurrentDir(DestDir) then
|
|
if not ForceDirectoriesRedir(False, DestDir) or not SetCurrentDir(DestDir) then
|
|
raise Exception.Create(FmtSetupMessage(msgErrorExtractionFailed, ['-1']));
|
|
raise Exception.Create(FmtSetupMessage(msgErrorExtractionFailed, ['-1']));
|
|
try
|
|
try
|
|
|
|
+ State.DisableFsRedir := DisableFsRedir;
|
|
State.ExpandedArchiveFileName := PathExpand(ArchiveFileName);
|
|
State.ExpandedArchiveFileName := PathExpand(ArchiveFileName);
|
|
State.ExpandedDestDir := AddBackslash(PathExpand(DestDir));
|
|
State.ExpandedDestDir := AddBackslash(PathExpand(DestDir));
|
|
State.LogBuffer := '';
|
|
State.LogBuffer := '';
|