Przeglądaj źródła

Merge branch 'main' into files-extractarchive

# Conflicts:
#	Projects/Src/Setup.MainFunc.pas
Martijn Laan 3 miesięcy temu
rodzic
commit
c51f019e2a
2 zmienionych plików z 51 dodań i 38 usunięć
  1. 1 1
      Projects/Src/Setup.Install.pas
  2. 50 37
      Projects/Src/Setup.MainFunc.pas

+ 1 - 1
Projects/Src/Setup.Install.pas

@@ -1800,7 +1800,7 @@ var
       Size: Integer64;
       Flags: TMakeDirFlags;
     begin
-      { Also see RecurseExternalFiles in Setup.MainFunc }
+      { Also see RecurseExternalFiles and RecurseExternalGetSizeOfFiles in Setup.MainFunc }
 
       Result := False;
 

+ 50 - 37
Projects/Src/Setup.MainFunc.pas

@@ -1752,7 +1752,7 @@ function EnumFiles(const EnumFilesProc: TEnumFilesProc;
     H: THandle;
     FindData: TWin32FindData;
   begin
-    { Also see RecurseExternalCopyFiles in Setup.Install }
+    { Also see RecurseExternalGetSizeOfFiles below and RecurseExternalCopyFiles in Setup.Install }
     Result := True;
 
     H := FindFirstFileRedir(DisableFsRedir, SearchBaseDir + SearchSubDir + SearchWildcard, FindData);
@@ -2720,8 +2720,9 @@ var
 
   function RecurseExternalGetSizeOfFiles(const DisableFsRedir: Boolean;
     const SearchBaseDir, SearchSubDir, SearchWildcard: String;
-    const SourceIsWildcard: Boolean; const RecurseSubDirs: Boolean): Integer64;
+    const SourceIsWildcard: Boolean; const Excludes: TStringList; const RecurseSubDirs: Boolean): Integer64;
   begin
+    { Also see RecurseExternalFiles above and RecurseExternalCopyFiles in Setup.Install }
     Result.Hi := 0;
     Result.Lo := 0;
 
@@ -2735,6 +2736,9 @@ var
             if FindData.dwFileAttributes and FILE_ATTRIBUTE_HIDDEN <> 0 then
               Continue;
 
+          if IsExcluded(SearchSubDir + FindData.cFileName, Excludes) then
+            Continue;
+
           var I: Integer64;
           I.Hi := FindData.nFileSizeHigh;
           I.Lo := FindData.nFileSizeLow;
@@ -2752,7 +2756,7 @@ var
             if IsRecurseableDirectory(FindData) then begin
               var I := RecurseExternalGetSizeOfFiles(DisableFsRedir, SearchBaseDir,
                 SearchSubDir + FindData.cFileName + '\', SearchWildcard,
-                SourceIsWildcard, RecurseSubDirs);
+                SourceIsWildcard, Excludes, RecurseSubDirs);
               Inc6464(Result, I);
             end;
           until not FindNextFile(H, FindData);
@@ -3443,40 +3447,49 @@ begin
 
   MinimumSpace := SetupHeader.ExtraDiskSpaceRequired;
 
-  for I := 0 to Entries[seFile].Count-1 do begin
-    with PSetupFileEntry(Entries[seFile][I])^ do begin
-      if LocationEntry <> -1 then begin { not an "external" file }
-        if Components = '' then { no types or a file that doesn't belong to any component }
-          if (Tasks = '') and (Check = '') then {don't count tasks and scripted entries}
-            Inc6464(MinimumSpace, PSetupFileLocationEntry(Entries[seFileLocation][LocationEntry])^.OriginalSize)
-      end else begin
-        if not(foExternalSizePreset in Options) then begin
-          try
-            if foExtractArchive in Options then begin
-              ExternalSize := ExternalArchiveGetSizeOfFiles(
-                ShouldDisableFsRedirForFileEntry(PSetupFileEntry(Entries[seFile][I])),
-                ExpandConst(SourceFilename), ExtractArchivePassword);
-            end else begin
-              if FileType <> ftUserFile then
-                SourceWildcard := NewParamStr(0)
-              else
-                SourceWildcard := ExpandConst(SourceFilename);
-              ExternalSize := RecurseExternalGetSizeOfFiles(
-                ShouldDisableFsRedirForFileEntry(PSetupFileEntry(Entries[seFile][I])),
-                PathExtractPath(SourceWildcard),
-                '', PathExtractName(SourceWildcard), IsWildcard(SourceWildcard),
-                foRecurseSubDirsExternal in Options);
-            end;
-          except
-            { Ignore exceptions. One notable exception we want to ignore is
-              the one about "app" not being initialized. }
-          end;
-        end;
-        if Components = '' then { no types or a file that doesn't belong to any component }
-          if (Tasks = '') and (Check = '') then {don't count tasks or scripted entries}
-            Inc6464(MinimumSpace, ExternalSize);
-      end;
-    end;
+  const LExcludes = TStringList.Create;
+  try
+    LExcludes.StrictDelimiter := True;
+    LExcludes.Delimiter := ',';
+
+	  for I := 0 to Entries[seFile].Count-1 do begin
+	    with PSetupFileEntry(Entries[seFile][I])^ do begin
+	      if LocationEntry <> -1 then begin { not an "external" file }
+	        if Components = '' then { no types or a file that doesn't belong to any component }
+	          if (Tasks = '') and (Check = '') then {don't count tasks and scripted entries}
+	            Inc6464(MinimumSpace, PSetupFileLocationEntry(Entries[seFileLocation][LocationEntry])^.OriginalSize)
+	      end else begin
+	        if not(foExternalSizePreset in Options) then begin
+	          try
+	            if foExtractArchive in Options then begin
+	              ExternalSize := ExternalArchiveGetSizeOfFiles(
+	                ShouldDisableFsRedirForFileEntry(PSetupFileEntry(Entries[seFile][I])),
+	                ExpandConst(SourceFilename), ExtractArchivePassword);
+	            end else begin
+	              if FileType <> ftUserFile then
+	                SourceWildcard := NewParamStr(0)
+	              else
+	                SourceWildcard := ExpandConst(SourceFilename);
+	              LExcludes.DelimitedText := Excludes;
+	              ExternalSize := RecurseExternalGetSizeOfFiles(
+	                ShouldDisableFsRedirForFileEntry(PSetupFileEntry(Entries[seFile][I])),
+	                PathExtractPath(SourceWildcard),
+	                '', PathExtractName(SourceWildcard), IsWildcard(SourceWildcard),
+	                LExcludes, foRecurseSubDirsExternal in Options);
+	            end;
+	          except
+	            { Ignore exceptions. One notable exception we want to ignore is
+	              the one about "app" not being initialized. }
+	          end;
+	        end;
+	        if Components = '' then { no types or a file that doesn't belong to any component }
+	          if (Tasks = '') and (Check = '') then {don't count tasks or scripted entries}
+	            Inc6464(MinimumSpace, ExternalSize);
+	      end;
+	    end;
+	  end;
+  finally
+    LExcludes.Free;
   end;
 
   for I := 0 to Entries[seComponent].Count-1 do