소스 검색

Work on third place. Is integrating very nicely 👍 Just two places left to change and perhaps a third, all marked with !!!. Also cleanup: RecurseExternalCopyFiles had an unneeded FileLocationFileNames parameter (which was also confusing: external + filelocation does not compute).

Martijn Laan 3 달 전
부모
커밋
ddd3590331
1개의 변경된 파일62개의 추가작업 그리고 15개의 파일을 삭제
  1. 62 15
      Projects/Src/Setup.Install.pas

+ 62 - 15
Projects/Src/Setup.Install.pas

@@ -31,7 +31,7 @@ uses
   Windows, SysUtils, Messages, Classes, Forms, ShlObj, Shared.Struct, Setup.UninstallLog, Shared.SetupTypes,
   Windows, SysUtils, Messages, Classes, Forms, ShlObj, Shared.Struct, Setup.UninstallLog, Shared.SetupTypes,
   SetupLdrAndSetup.InstFunc, Setup.InstFunc, Setup.InstFunc.Ole, Setup.SecurityFunc, SetupLdrAndSetup.Messages,
   SetupLdrAndSetup.InstFunc, Setup.InstFunc, Setup.InstFunc.Ole, Setup.SecurityFunc, SetupLdrAndSetup.Messages,
   Setup.MainFunc, Setup.LoggingFunc, Setup.FileExtractor, Shared.FileClass,
   Setup.MainFunc, Setup.LoggingFunc, Setup.FileExtractor, Shared.FileClass,
-  Compression.Base, SHA256, PathFunc, ISSigFunc, Shared.CommonFunc.Vcl,
+  Compression.Base, SHA256, PathFunc, ISSigFunc, Shared.CommonFunc.Vcl, Compression.SevenZipDLLDecoder,
   Shared.CommonFunc, SetupLdrAndSetup.RedirFunc, Shared.Int64Em, Shared.SetupMessageIDs,
   Shared.CommonFunc, SetupLdrAndSetup.RedirFunc, Shared.Int64Em, Shared.SetupMessageIDs,
   Setup.WizardForm, Shared.DebugStruct, Setup.DebugClient, Shared.VerInfoFunc, Setup.ScriptRunner, Setup.RegDLL, Setup.Helper,
   Setup.WizardForm, Shared.DebugStruct, Setup.DebugClient, Shared.VerInfoFunc, Setup.ScriptRunner, Setup.RegDLL, Setup.Helper,
   Shared.ResUpdateFunc, Setup.DotNetFunc, TaskbarProgressFunc, NewProgressBar, RestartManager,
   Shared.ResUpdateFunc, Setup.DotNetFunc, TaskbarProgressFunc, NewProgressBar, RestartManager,
@@ -1234,7 +1234,7 @@ var
           CurFileDateValid := True;
           CurFileDateValid := True;
         end
         end
         else
         else
-          CurFileDateValid := GetFileDateTime(DisableFsRedir, ASourceFile, CurFileDate);
+          CurFileDateValid := GetFileDateTime(DisableFsRedir, ASourceFile, CurFileDate); {!!!}
         if CurFileDateValid then
         if CurFileDateValid then
           LogFmt('Time stamp of our file: %s', [FileTimeToStr(CurFileDate)])
           LogFmt('Time stamp of our file: %s', [FileTimeToStr(CurFileDate)])
         else
         else
@@ -1456,7 +1456,7 @@ var
           { If the file is compressed in the setup package, has the same file
           { If the file is compressed in the setup package, has the same file
             already been copied somewhere else? If so, just make a duplicate of
             already been copied somewhere else? If so, just make a duplicate of
             that file instead of extracting it over again. }
             that file instead of extracting it over again. }
-          if (SourceFile = '') and
+          if (SourceFile = '') and (FileLocationFilenames <> nil) and
              (FileLocationFilenames[CurFile^.LocationEntry] <> '') and
              (FileLocationFilenames[CurFile^.LocationEntry] <> '') and
              NewFileExistsRedir(DisableFsRedir, FileLocationFilenames[CurFile^.LocationEntry]) then
              NewFileExistsRedir(DisableFsRedir, FileLocationFilenames[CurFile^.LocationEntry]) then
             SourceFile := FileLocationFilenames[CurFile^.LocationEntry];
             SourceFile := FileLocationFilenames[CurFile^.LocationEntry];
@@ -1492,7 +1492,7 @@ var
                 not (foDontVerifyChecksum in CurFile^.Options));
                 not (foDontVerifyChecksum in CurFile^.Options));
             end
             end
             else begin
             else begin
-              { Copy an external file, or a duplicated non-external file }
+              { Copy an external file, or a duplicated non-external file } {!!!}
               SourceF := TFileRedir.Create(DisableFsRedir, SourceFile, fdOpenExisting, faRead, fsRead);
               SourceF := TFileRedir.Create(DisableFsRedir, SourceFile, fdOpenExisting, faRead, fsRead);
               try
               try
                 LastOperation := SetupMessages[msgErrorCopying];
                 LastOperation := SetupMessages[msgErrorCopying];
@@ -1790,8 +1790,8 @@ var
 
 
     function RecurseExternalCopyFiles(const DisableFsRedir: Boolean;
     function RecurseExternalCopyFiles(const DisableFsRedir: Boolean;
       const SearchBaseDir, SearchSubDir, SearchWildcard: String; const SourceIsWildcard: Boolean;
       const SearchBaseDir, SearchSubDir, SearchWildcard: String; const SourceIsWildcard: Boolean;
-      const Excludes: TStringList; const CurFile: PSetupFileEntry; const FileLocationFilenames: TStringList;
-      var ExpectedBytesLeft: Integer64; var ConfirmOverwriteOverwriteAll, PromptIfOlderOverwriteAll: TOverwriteAll;
+      const Excludes: TStringList; const CurFile: PSetupFileEntry; var ExpectedBytesLeft: Integer64;
+      var ConfirmOverwriteOverwriteAll, PromptIfOlderOverwriteAll: TOverwriteAll;
       var WarnedPerUserFonts: Boolean): Boolean;
       var WarnedPerUserFonts: Boolean): Boolean;
     begin
     begin
       { Also see RecurseExternalFiles and RecurseExternalGetSizeOfFiles in Setup.MainFunc
       { Also see RecurseExternalFiles and RecurseExternalGetSizeOfFiles in Setup.MainFunc
@@ -1835,8 +1835,8 @@ var
                   files is greater than when we last checked }
                   files is greater than when we last checked }
                 Size := ExpectedBytesLeft;
                 Size := ExpectedBytesLeft;
               end;
               end;
-              ProcessFileEntry(CurFile, DisableFsRedir, SourceFile, DestName,
-                FileLocationFilenames, Size, ConfirmOverwriteOverwriteAll, PromptIfOlderOverwriteAll,
+              ProcessFileEntry(CurFile, DisableFsRedir, SourceFile, DestName, nil,
+                Size, ConfirmOverwriteOverwriteAll, PromptIfOlderOverwriteAll,
                 WarnedPerUserFonts);
                 WarnedPerUserFonts);
               Dec6464(ExpectedBytesLeft, Size);
               Dec6464(ExpectedBytesLeft, Size);
             end;
             end;
@@ -1854,8 +1854,8 @@ var
               if IsRecurseableDirectory(FindData) then
               if IsRecurseableDirectory(FindData) then
                 Result := RecurseExternalCopyFiles(DisableFsRedir, SearchBaseDir,
                 Result := RecurseExternalCopyFiles(DisableFsRedir, SearchBaseDir,
                   SearchSubDir + FindData.cFileName + '\', SearchWildcard,
                   SearchSubDir + FindData.cFileName + '\', SearchWildcard,
-                  SourceIsWildcard, Excludes, CurFile, FileLocationFileNames,
-                  ExpectedBytesLeft, ConfirmOverwriteOverwriteAll, PromptIfOlderOverwriteAll,
+                  SourceIsWildcard, Excludes, CurFile, ExpectedBytesLeft,
+                  ConfirmOverwriteOverwriteAll, PromptIfOlderOverwriteAll,
                   WarnedPerUserFonts) or Result;
                   WarnedPerUserFonts) or Result;
             until not FindNextFile(H, FindData);
             until not FindNextFile(H, FindData);
           finally
           finally
@@ -1887,6 +1887,47 @@ var
       ProcessEvents;
       ProcessEvents;
     end;
     end;
 
 
+     function RecurseExternalArchiveCopyFiles(const DisableFsRedir: Boolean;
+      const ArchiveFilename, Password: String; const CurFile: PSetupFileEntry;
+      var ExpectedBytesLeft: Integer64; var ConfirmOverwriteOverwriteAll, PromptIfOlderOverwriteAll: TOverwriteAll;
+      var WarnedPerUserFonts: Boolean): Boolean;
+    begin
+      { See above }
+
+      Result := False;
+
+      var FindData: TWin32FindData;
+      var ArchiveIndex := 0;
+      var H := ArchiveFindFirstFileRedir(DisableFsRedir, ArchiveFilename, Password, FindData);
+      if H <> INVALID_HANDLE_VALUE then begin
+        try
+          repeat
+            if FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY = 0 then begin
+              Result := True;
+              var SourceFile := ArchiveIndex.ToString; {!!!}
+              if foCustomDestName in CurFile^.Options then
+                InternalError('Unexpected custom DestName');
+              const DestName = ExpandConst(CurFile^.DestName) + FindData.cFileName;
+              var Size: Integer64;
+              Size.Hi := FindData.nFileSizeHigh;
+              Size.Lo := FindData.nFileSizeLow;
+              if Compare64(Size, ExpectedBytesLeft) > 0 then begin
+                { Don't allow the progress bar to overflow if the size of the
+                  files is greater than when we last checked }
+                Size := ExpectedBytesLeft;
+              end;
+              ProcessFileEntry(CurFile, DisableFsRedir, SourceFile, DestName,
+                nil, Size, ConfirmOverwriteOverwriteAll, PromptIfOlderOverwriteAll,
+                WarnedPerUserFonts);
+              Dec6464(ExpectedBytesLeft, Size);
+            end;
+          until not FindNextFile(H, FindData);
+        finally
+          Windows.FindClose(H);
+        end;
+      end;
+    end;
+
   var
   var
     I: Integer;
     I: Integer;
     CurFileNumber: Integer;
     CurFileNumber: Integer;
@@ -1949,11 +1990,17 @@ var
             repeat
             repeat
               SetProgress(ProgressBefore);
               SetProgress(ProgressBefore);
               ExpectedBytesLeft := CurFile^.ExternalSize;
               ExpectedBytesLeft := CurFile^.ExternalSize;
-              FoundFiles := RecurseExternalCopyFiles(DisableFsRedir,
-                PathExtractPath(SourceWildcard), '', PathExtractName(SourceWildcard),
-                IsWildcard(SourceWildcard), Excludes, CurFile, FileLocationFileNames,
-                ExpectedBytesLeft, ConfirmOverwriteOverwriteAll, PromptIfOlderOverwriteAll,
-                WarnedPerUserFonts);
+              if foExtractArchive in CurFile^.Options then
+                FoundFiles := RecurseExternalArchiveCopyFiles(DisableFsRedir,
+                  SourceWildcard, CurFile^.ExtractArchivePassword, CurFile,
+                  ExpectedBytesLeft, ConfirmOverwriteOverwriteAll, PromptIfOlderOverwriteAll,
+                  WarnedPerUserFonts)
+              else
+                FoundFiles := RecurseExternalCopyFiles(DisableFsRedir,
+                  PathExtractPath(SourceWildcard), '', PathExtractName(SourceWildcard),
+                  IsWildcard(SourceWildcard), Excludes, CurFile,
+                  ExpectedBytesLeft, ConfirmOverwriteOverwriteAll, PromptIfOlderOverwriteAll,
+                  WarnedPerUserFonts);
             until FoundFiles or
             until FoundFiles or
                   (foSkipIfSourceDoesntExist in CurFile^.Options) or
                   (foSkipIfSourceDoesntExist in CurFile^.Options) or
                   AbortRetryIgnoreTaskDialogMsgBox(
                   AbortRetryIgnoreTaskDialogMsgBox(