このようにするのは少し奇妙で、部分的にしか機能しません。
...
StrCmp ${res} "" 0 +2 ; +1 and 0 is the same, jumps to next instruction
StrCpy ${res} 1 ; No need to do math here
IntOp ${res} ${res} + 0 ; NaN + 0 = 0 but what if you read a number from the file?
ファイルが番号で始まる可能性がある場合は、zbynourが提案したようにジャンプする必要があります。
...
StrCmp ${res} "" 0 +3
StrCpy ${res} 1
Goto +2
StrCpy ${res} 0
テストを反転すると、同じ数の命令で必要なものを取得できます。
!macro IsFileNOTEmpty fName res
!insertmacro ReadFile "${fName}" ${res}
StrCmp ${res} "" +2 0
StrCpy ${res} 1 ; Or IntOp ${res} ${res} | 1 if you really wanted to do extra math ;)
IntOp ${res} ${res} + 0
!macroend
またはさらに良い:
!macro IsFileEmpty fName res
!insertmacro ReadFile "${fName}" ${res}
StrLen ${res} ${res} ; If this is enough depends on how you want to deal with newlines at the start of the file (\r or \n)
!macroend
...このコードはすべて、ファイルがテキストで始まるかどうかをテストすることを前提としています。ファイルが0バイトで始まる場合は、常にファイルが空であると表示されます。したがって、ファイルにバイナリコンテンツが含まれている場合は、実際のサイズをバイト単位でテストするFranciscoRのコードを使用する必要があります。