我可以 push/pop NSIS 中 SetOverwrite 标志的值吗?

Can I push/pop the value of the SetOverwrite flag in NSIS?

在函数或宏中,我经常需要特定的 SetOverwrite 行为。但是,我更喜欢让这些子程序自行清理(不要在堆栈上留下非 return 值,保持 OutPath 不变,不改变全局状态等),这样我就不必复制每次我想做某事时的一系列设置命令——为了使代码更具可读性。

有没有办法用 SetOverwrite 完成这个?我可以 "detect" 它,保存它,然后以某种方式恢复它吗?

我看不到 GetOverwrite 函数。 SetOverwrite 文档引用了 "overwrite flag,",但我找不到具体的引用来说明它到底是什么。有什么方法可以获取此(或任意)标志的值?

不,没有您可以与之互动的旗帜。 plug-ins 可以控制一组标志,但覆盖模式不是其中之一。

我认为覆盖模式与 File 指令交互,因此有一些 compile-time 限制。

你唯一能做的就是

${If} $something = "whatever"
  SetOverwrite on
  File "foo.txt"
${Else}
  SetOverwrite ifnewer
  File "foo.txt"
${EndIf}

SetOverwrite 适用于脚本后面的所有其他 File 指令,因此很遗憾无法 push/pop 它的状态。

来自文档:

4.8.2 Compiler Flags

The following commands affect how the compiler generates code and compresses data. Unless otherwise noted, these commands are valid anywhere in the script and affect every line below where each one is placed (until overridden by another command). They cannot be jumped over using flow control instructions.