Просмотр исходного кода

Added new IsWildcard and WildcardMatch support functions.
Added wildcard support to WizardImage(Small)File.

Martijn Laan 7 лет назад
Родитель
Сommit
227e1c9cac
7 измененных файлов с 63 добавлено и 22 удалено
  1. 2 2
      ISHelp/isetup.xml
  2. 10 0
      ISHelp/isxfunc.xml
  3. 1 1
      Projects/CompMsgs.pas
  4. 37 15
      Projects/Compile.pas
  5. 4 2
      Projects/ScriptFunc.pas
  6. 6 0
      Projects/ScriptFunc_R.pas
  7. 3 2
      whatsnew.htm

+ 2 - 2
ISHelp/isetup.xml

@@ -4461,7 +4461,7 @@ DiskSliceSize=1457664
 <setuptopic directive="WizardImageFile">
 <setupdefault><tt>compiler:WIZMODERNIMAGE.BMP</tt></setupdefault>
 <body>
-<p>Specifies the name(s) of the bitmap file(s) to display on the left side of the wizard. The files(s) must be located in your installation's <link topic="sourcedirectorynotes">source directory</link> when running the Setup Compiler, unless a fully qualified pathname is specified or the pathname is prefixed by "compiler:", in which case it looks for the file in the Compiler directory.</p>
+<p>Specifies the name(s) of the bitmap file(s) to display on the left side of the wizard. Wildcards are supported and the files(s) must be located in your installation's <link topic="sourcedirectorynotes">source directory</link> when running the Setup Compiler, unless a fully qualified pathname is specified or the pathname is prefixed by "compiler:", in which case it looks for the file in the Compiler directory.</p>
 <p>256-color bitmaps may not display correctly in 256-color mode, since it does not handle palettes.</p>
 <p>When multiple files are specified, Setup will automatically select the one which best matches the system's DPI setting. The recommended size of the bitmap per DPI setting is:</p>
 <table>
@@ -4484,7 +4484,7 @@ DiskSliceSize=1457664
 <setuptopic directive="WizardSmallImageFile">
 <setupdefault><tt>compiler:WIZMODERNSMALLIMAGE.BMP</tt></setupdefault>
 <body>
-<p>Specifies the name(s) of the bitmap file(s) to display in the upper right corner of the wizard. The file(s) must be located in your installation's <link topic="sourcedirectorynotes">source directory</link> when running the Setup Compiler, unless a fully qualified pathname is specified or the pathname is prefixed by "compiler:", in which case it looks for the file in the Compiler directory.</p>
+<p>Specifies the name(s) of the bitmap file(s) to display in the upper right corner of the wizard. Wildcards are supported and the file(s) must be located in your installation's <link topic="sourcedirectorynotes">source directory</link> when running the Setup Compiler, unless a fully qualified pathname is specified or the pathname is prefixed by "compiler:", in which case it looks for the file in the Compiler directory.</p>
 <p>256-color bitmaps may not display correctly in 256-color mode, since it does not handle palettes.</p>
 <p>When multiple files are specified, Setup will automatically select the one which best matches the system's DPI setting. The recommended size of the bitmap per DPI setting is:</p>
 <table>

+ 10 - 0
ISHelp/isxfunc.xml

@@ -874,6 +874,16 @@ end;</pre></example>
         <prototype>function CompareStr(const S1, S2: string): Integer;</prototype>
         <description><p>Compares S1 to S2, with case-sensitivity. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.</p></description>
       </function>
+      <function>
+        <name>IsWildcard</name>
+        <prototype>function IsWildcard(const Pattern: String): Boolean;</prototype>
+        <description><p>Returns True if the specified pattern contains a wildcard.</p></description>
+      </function>
+      <function>
+        <name>WildcardMatch</name>
+        <prototype>function WildcardMatch(const Text, Pattern: String): Boolean;</prototype>
+        <description><p>Returns True if the specified text matches the specified pattern.</p></description>
+      </function>
     </subcategory>
     <subcategory>
       <function>

+ 1 - 1
Projects/CompMsgs.pas

@@ -187,7 +187,7 @@ const
   SCompilerMustNotUsePreviousLanguage = 'UsePreviousLanguage must be set to "no" when AppId includes constants';
   SCompilerDirectiveNotUsingDefault = 'The [Setup] section directive "%s" is not assuming a default value because %s includes constants.';
   SCompilerDirectiveNotUsingPreferredDefault = 'The [Setup] section directive "%s" is defaulting to %s because %s includes constants.';
-  SCompilerDirectiveCloseApplicationsFilterTooLong = 'The [Setup] section directive "CloseApplicationsFilter" contains a pattern that is too long';
+  SCompilerDirectivePatternTooLong = 'The [Setup] section directive "%s" contains a pattern that is too long';
   SCompilerOutputBaseFileNameSetup = 'Setting the [Setup] section "OutputBaseFileName" to "setup" is not recommended, all executables named "setup.exe" are shimmed by Windows application compatibility to load additional DLLs, such as version.dll.' + ' These DLLs are loaded unsafely by Windows and can be hijacked. Use a different name, for example "mysetup".';
 
   { Signing }

+ 37 - 15
Projects/Compile.pas

@@ -507,7 +507,7 @@ type
     procedure WriteDebugEntry(Kind: TDebugEntryKind; Index: Integer);
     procedure WriteCompiledCodeText(const CompiledCodeText: Ansistring);
     procedure WriteCompiledCodeDebugInfo(const CompiledCodeDebugInfo: AnsiString);
-    function CreateMemoryStreamsFromFiles(const AFiles: String): TList;
+    function CreateMemoryStreamsFromFiles(const ADirectiveName, AFiles: String): TList;
   public
     AppData: Longint;
     CallbackProc: TCompilerCallbackProc;
@@ -720,16 +720,20 @@ begin
   until (Result <> '') or (S = '');
 end;
 
-function TSetupCompiler.CreateMemoryStreamsFromFiles(const AFiles: String): TList;
+function TSetupCompiler.CreateMemoryStreamsFromFiles(const ADirectiveName, AFiles: String): TList;
 
   procedure AddFile(const Filename: String);
   begin
     AddStatus(Format(SCompilerStatusReadingInFile, [FileName]));
-    Result.Add(CreateMemoryStreamFromFile(FileName));    
+    Result.Add(CreateMemoryStreamFromFile(FileName));
   end;
 
 var
-  S, Filename: String;
+  Filename, SearchSubDir: String;
+  AFilesList: TStringList;
+  I: Integer;
+  H: THandle;
+  FindData: TWin32FindData;
 begin
   Result := TList.Create;
   try
@@ -739,14 +743,32 @@ begin
     Filename := PrependSourceDirName(AFiles);
     if NewFileExists(Filename) then
        AddFile(Filename)
-    else begin 
-      S := AFiles;
-      while True do begin
-        Filename := ExtractStr(S, ',');
-        if Filename = '' then
-          Break;
-        Filename := PrependSourceDirName(Filename);
-        AddFile(Filename);
+    else begin
+      AFilesList := TStringList.Create;
+      try
+        ProcessWildcardsParameter(AFiles, AFilesList,
+          Format(SCompilerDirectivePatternTooLong, [ADirectiveName]));
+        for I := 0 to AFilesList.Count-1 do begin
+          Filename := PrependSourceDirName(AFilesList[I]);
+          if IsWildcard(FileName) then begin
+            H := FindFirstFile(PChar(Filename), FindData);
+            if H <> INVALID_HANDLE_VALUE then begin
+              try
+                SearchSubDir := PathExtractPath(Filename);
+                repeat
+                  if FindData.dwFileAttributes and (FILE_ATTRIBUTE_DIRECTORY or FILE_ATTRIBUTE_HIDDEN) <> 0 then
+                    Continue;
+                   AddFile(SearchSubDir + FindData.cFilename);
+                until not FindNextFile(H, FindData);
+              finally
+                Windows.FindClose(H);
+              end;
+            end;
+          end else
+            AddFile(Filename);  { use the case specified in the script }
+        end;
+      finally
+        AFilesList.Free;
       end;
     end;
   except
@@ -3780,7 +3802,7 @@ begin
         AIncludes := TStringList.Create;
         try
           ProcessWildcardsParameter(Value, AIncludes,
-            SCompilerDirectiveCloseApplicationsFilterTooLong);
+            Format(SCompilerDirectivePatternTooLong, ['CloseApplicationsFilter']));
           SetupHeader.CloseApplicationsFilter := StringsToCommaString(AIncludes);
         finally
           AIncludes.Free;
@@ -8725,10 +8747,10 @@ begin
     { Read wizard image }
     LineNumber := SetupDirectiveLines[ssWizardImageFile];
     AddStatus(Format(SCompilerStatusReadingFile, ['WizardImageFile']));
-    WizardImages := CreateMemoryStreamsFromFiles(WizardImageFile);
+    WizardImages := CreateMemoryStreamsFromFiles('WizardImageFile', WizardImageFile);
     LineNumber := SetupDirectiveLines[ssWizardSmallImageFile];
     AddStatus(Format(SCompilerStatusReadingFile, ['WizardSmallImageFile']));
-    WizardSmallImages := CreateMemoryStreamsFromFiles(WizardSmallImageFile);
+    WizardSmallImages := CreateMemoryStreamsFromFiles('WizardSmallImageFile', WizardSmallImageFile);
     LineNumber := 0;
 
     { Prepare Setup executable & signed uninstaller data }

+ 4 - 2
Projects/ScriptFunc.pas

@@ -54,7 +54,7 @@ const
   );
 
    { CmnFunc2 }
-  CmnFunc2Table: array [0..55] of AnsiString =
+  CmnFunc2Table: array [0..57] of AnsiString =
   (
     'function FileExists(const Name: String): Boolean;',
     'function DirExists(const Name: String): Boolean;',
@@ -113,7 +113,9 @@ const
     'function GetUILanguage: Integer;',
     'function AddPeriod(const S: String): String;',
     'function CharLength(const S: String; const Index: Integer): Integer;',
-    'function SetNTFSCompression(const FileOrDir: String; Compress: Boolean): Boolean;'
+    'function SetNTFSCompression(const FileOrDir: String; Compress: Boolean): Boolean;',
+    'function IsWildcard(const Pattern: String): Boolean;',
+    'function WildcardMatch(const Text, Pattern: String): Boolean;'
   );
 
   { Install }

+ 6 - 0
Projects/ScriptFunc_R.pas

@@ -736,6 +736,12 @@ begin
     Stack.SetInt(PStart, PathCharLength(Stack.GetString(PStart-1), Stack.GetInt(PStart-2)));
   end else if Proc.Name = 'SETNTFSCOMPRESSION' then begin
     Stack.SetBool(PStart, SetNTFSCompressionRedir(ScriptFuncDisableFsRedir, Stack.GetString(PStart-1), Stack.GetBool(PStart-2)));
+  end else if Proc.Name = 'ISWILDCARD' then begin
+    Stack.SetBool(PStart, IsWildcard(Stack.GetString(PStart-1)));
+  end else if Proc.Name = 'WILDCARDMATCH' then begin
+    S := Stack.GetString(PStart-1);
+    N := Stack.GetString(PStart-2);
+    Stack.SetBool(PStart, WildcardMatch(PChar(S), PChar(N)));
   end else
     Result := False;
 end;

+ 3 - 2
whatsnew.htm

@@ -34,7 +34,7 @@ For conditions of distribution and use, see <a href="http://www.jrsoftware.org/f
 <li>Regardless of the version of Windows, if the installation is administrative then you should be careful about making any per-user area changes: such changes may not achieve what you are intending. The compiler will now warn you about this, which can be disabled using new [Setup] section directive <tt>UsedUserAreasWarning</tt>.</tt>
 <li>Improved support for high DPI systems:
 <ul>
-  <li>The <tt>WizardImageFile</tt> and <tt>WizardSmallImageFile</tt> [Setup] section directives now may list multiple files. When multiple files are specified, Setup will automatically select the one which best matches the system's DPI setting. See the help file for a list of recommended sizes. Note: when you test this be sure to first log out and back in after any DPI change.</li>
+  <li>The <tt>WizardImageFile</tt> and <tt>WizardSmallImageFile</tt> [Setup] section directives now may list multiple files. This support wildcards. When multiple files are specified, Setup will automatically select the one which best matches the system's DPI setting. See the help file for a list of recommended sizes. Note: when you test this be sure to first log out and back in after any DPI change.</li>
   <li>If the <tt>WizardImageStretch</tt> [Setup] section directive is set to <tt>yes</tt> (which it is by default) then the quality of the stretching that occurs if the best matching wizard image is still larger or smaller than required has been improved (<a href="https://i.imgur.com/BNtbQd9.png">before</a> and <a href="https://i.imgur.com/BeFyqfn.png">after</a>). Also applies to any <tt>TBitmapImage</tt> which uses stretching.</li>
 </ul>
 </li>
@@ -48,7 +48,8 @@ For conditions of distribution and use, see <a href="http://www.jrsoftware.org/f
 <li>Pascal Scripting changes:
 <ul>
   <li>Unicode Inno Setup: Unicode is now supported for the input source. For example, where before you had to write <tt>S := #$0100 + #$0101 + 'Aa';</tt> you can now write <tt>S := '&#x0100;&#x0101;Aa';</tt> directly. Also see the new <i>UnicodeExample1.iss</i> example script.</li>
-  <li>Added new <tt>IsX86</tt>, <tt>IsX64</tt>, <tt>IsIA64</tt>, and <tt>IsARM64</tt> support functions.</li>
+  <li>Added new <tt>IsX86</tt>, <tt>IsX64</tt>, <tt>IsIA64</tt> and <tt>IsARM64</tt> support functions.</li>
+  <li>Added new <tt>IsWildcard</tt> and <tt>WildcardMatch</tt> support functions.</li>
   <li>/LOG: Now logs DLL function imports.</li>
 </ul>
 </li>