InstalledFiles.nsh 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. ; Included by LYNX.nsi (and by the test installer of round 190nr). Needs LogicLib.nsh and TextFunc.nsh.
  2. ;; Round 190nr: what this installer owns in $INSTDIR (top-level names). Every name a File command in LYNX.nsi writes must be
  3. ;; here, and core/UpdateCheck.cpp installEntries() needs every name that is new in this version. The list is written
  4. ;; to installed-files.txt; an install over a NEWER version reads that version's list first and removes the names this
  5. ;; version doesn't own, so going back leaves nothing of the newer version behind (0.1.29's installer left 0.1.30's
  6. ;; licenses\). Installers of 0.1.30 and older don't do this: for them the newer version's --apply-update helper cleans
  7. ;; up (src/ui/Updater.cpp removeNewerLeftovers). A 0.1.30 or older setup run by hand over a newer version can't be cleaned
  8. ;; up from the newer side (its script is fixed and the newer version doesn't run); what it leaves is harmless and goes
  9. ;; with the next 0.1.31+ install or uninstall.
  10. !macro ForEachOwned M
  11. !insertmacro ${M} "LYNX.exe"
  12. !insertmacro ${M} "LYNX.pdb"
  13. !insertmacro ${M} "onnxruntime.dll"
  14. !insertmacro ${M} "LICENSE"
  15. !insertmacro ${M} "THIRD_PARTY.md"
  16. !insertmacro ${M} "PRIVACY.md"
  17. !insertmacro ${M} "licenses"
  18. !insertmacro ${M} "Demo.lynx"
  19. !insertmacro ${M} "LYNX-bridge32.exe"
  20. !insertmacro ${M} "lynx-asio.dll"
  21. !insertmacro ${M} "lynx-asio32.dll"
  22. !insertmacro ${M} "Register LYNX ASIO.bat"
  23. !insertmacro ${M} "Unregister LYNX ASIO.bat"
  24. !insertmacro ${M} "Uninstall.exe"
  25. !insertmacro ${M} "installed-files.txt"
  26. !macroend
  27. !macro IsOwnedName NAME
  28. ${If} $R1 == "${NAME}"
  29. StrCpy $R2 1
  30. ${EndIf}
  31. !macroend
  32. !macro WriteOwnedName NAME
  33. FileWrite $R0 "${NAME}$\r$\n"
  34. !macroend
  35. ; $R1 = a name from installed-files.txt -> $R2 = 1 when it is a plain top-level name this installer does not own
  36. Function IsStrayName
  37. StrCpy $R2 0
  38. !insertmacro ForEachOwned IsOwnedName
  39. ${If} $R2 == 1
  40. StrCpy $R2 0
  41. Return
  42. ${EndIf}
  43. ${If} $R1 == ""
  44. ${OrIf} $R1 == "."
  45. ${OrIf} $R1 == ".."
  46. Return
  47. ${EndIf}
  48. StrLen $R3 $R1
  49. StrCpy $R4 0
  50. ${DoWhile} $R4 < $R3
  51. StrCpy $R5 $R1 1 $R4
  52. ${If} $R5 == "\"
  53. ${OrIf} $R5 == "/"
  54. ${OrIf} $R5 == ":"
  55. Return
  56. ${EndIf}
  57. IntOp $R4 $R4 + 1
  58. ${Loop}
  59. StrCpy $R2 1
  60. FunctionEnd
  61. Function RemoveNewerLeftovers
  62. ClearErrors
  63. FileOpen $R0 "$INSTDIR\installed-files.txt" r
  64. ${If} ${Errors}
  65. Return
  66. ${EndIf}
  67. ${Do}
  68. ClearErrors
  69. FileRead $R0 $R1
  70. ${If} ${Errors}
  71. ${ExitDo}
  72. ${EndIf}
  73. ${TrimNewLines} $R1 $R1
  74. Call IsStrayName
  75. ${If} $R2 == 1
  76. ${If} ${FileExists} "$INSTDIR\$R1\*.*"
  77. RMDir /r "$INSTDIR\$R1"
  78. ${Else}
  79. Delete "$INSTDIR\$R1"
  80. ${EndIf}
  81. ${EndIf}
  82. ${Loop}
  83. FileClose $R0
  84. FunctionEnd
  85. Function WriteInstalledFiles
  86. FileOpen $R0 "$INSTDIR\installed-files.txt" w
  87. !insertmacro ForEachOwned WriteOwnedName
  88. FileClose $R0
  89. FunctionEnd