1 comment

  • Avatar

    In the recently released InstallBuilder 6.2.5 a new filtering mechanism has been introduced for folders. This new functionality will allow you to pack the contents of a folder instead of including the folder itself and to apply filters to include or exclude scpecific files. For example, if we have a folder "documentation" and we want to pack a subset of its contents and unpack it to ${installdir}/myDocs, we just need to use the snippet below:

       <description>Documentation Files</description>
           <distributionDirectory allowWildcards="1">

    In the above example, we have packed all of the .txt files related with "project-1" but not our secret "project-1-secret.txt"

    Here are the new tags:

    • <allowWildcards> : This tag determines the behavior of the filtering mechanism. If it is set to "0" (the default), there won't be any global pattern interpretation and patterns will be taken as literal strings. For example, if we define <origin>/some/path/to/documentation/*</origin>, the installer will look for a folder named "*" inside the /some/path/to/documentation/ directory. In addition, the includeFiles and excludeFiles tags will be ignored. This will be equivalent to the old behavior.

    However, if allowWildcards is set to "1", the <origin> will be expanded and the installer will generate a list of matching files.

    • <includeFiles> : This tag allows you to select files over the matches produced by the <origin> tag when wildcards are enabled. The default value of the <includeFiles> tag is "*" so all the files matched by the <origin> tag will be packed.

    • <excludeFiles> : Once the list of files has been filtered with the <includeFiles> pattern, the <excludefiles> filter will be applied over the result. The default value of this tag is empty so no filter is applied. This tag is ignored as well if wildcards are disabled.

    The pattern interpretation in the <origin>, <includeFiles> and <excludeFiles> does not follow the same rules. The <origin> pattern is expanded over the existing files, like a "dir c:\Program Files\*txt" on Windows or "ls ~/*txt" on Unix. Forward and backwards slashes are normalized according to the platform. However, the patterns in the <includeFiles> and <excludeFiles> tags follow a stricter format:

    • Forward slashes are used as path separators, which let us escape special characters using backslashes. For example, to match .txt files, you must use /.txt files in both Windows and Unix systems.
    • The pattern is applied over the full path of the files and a string comparison is performed: <includeFiles>my.txt<includeFiles> won't work because it will compare "/some/path/to/my.txt" with "my.txt". */my.txt has to be used instead.
    • Multiple patterns can be included separated by ; or \n characters:

      <distributionDirectory allowWildcards="1"> <origin>/some/path/*</origin> <includeFiles>*/*.txt;*/*.jpg;*/*.bmp</includeFiles> <excludeFiles>*/*secret*.txt;*/myImage.bmp</excludeFiles> </distributionDirectory>

    The special characters used in all the patterns are listed below:

    • ? : Matches any single character.
    • * : Matches any sequence of zero or more characters.
    • [chars] : Matches any single character in chars. If chars contains a sequence of the form a-b then any character between a and b (inclusive) will match.
    • {a,b,...} : Matches any of the strings a, b, etc.How to use file filtering on folders.

Please sign in to leave a comment.