Tom
Tom

Reputation: 3637

Inno Setup - wildcard and specific "Source" covering same file - which instruction takes priority?

Suppose I have:

[Files]
Source: *.*; DestDir: {app}; Flags: recursesubdirs
Source: address.txt; DestDir: {app}; Flags: onlyifdoesntexist

Which takes precedence and is the behavior defined? I would think that either the specific or last listed of the two overrides depending on the internal logic, but would be nice if he behavior was defined.


If they both get executed (as an answer indicates), I will instead need to use something like:

[Files]
Source: *.*; DestDir: {app}; Flags: recursesubdirs; Excludes: "address.txt"
Source: address.txt; DestDir: {app}; Flags: onlyifdoesntexist

Upvotes: 2

Views: 586

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202504

There is (almost) nothing special happening.

Both rules are processed, in the definition order, as any other rules.

  • First the address.txt is installed by the first mask rule.

  • And then the second specific rule is processed (but in this specific case, it does nothing due to the onlyifdoesntexist flag).

2017-05-28 15:39:52.678   -- File entry --
2017-05-28 15:39:52.678   Dest filename: C:\Program Files\My Program\address.txt
2017-05-28 15:39:52.678   Time stamp of our file: 2017-05-28 15:39:20.000
2017-05-28 15:39:52.678   Installing the file.
2017-05-28 15:39:52.678   Successfully installed the file.
2017-05-28 15:39:52.678   -- File entry --
2017-05-28 15:39:52.678   Dest filename: C:\Program Files\My Program\address.txt
2017-05-28 15:39:52.678   Time stamp of our file: 2017-05-28 15:39:20.000
2017-05-28 15:39:52.678   Dest file exists.
2017-05-28 15:39:52.678   Skipping due to "onlyifdoesntexist" flag.

The only special thing happening with these two rules, is that Inno Setup identifies that a same file (address.txt) is being referred to twice, so it stores the file only once to the installer.

You will see only one record for address.txt in the compiler output:

   Compressing: C:\source\address.txt

But that would happen with any rules (even two specific rules) referring to the same file. So it's not about wildcard vs. specific rule.


When you decompile the installer, you will see that the wildcard rule is actually expanded to individual rules by the compiler.

So you effectively get this:

[Files]
Source: "???\address.txt"; DestDir: "{app}"; MinVersion: 0.0,5.0; 
Source: "???\address.txt"; DestDir: "{app}"; MinVersion: 0.0,5.0; Flags: onlyifdoesntexist 

Upvotes: 2

Related Questions