diff options
| author | David <daullmer@gmail.com> | 2020-06-14 12:43:10 +0200 |
|---|---|---|
| committer | David <daullmer@gmail.com> | 2020-06-14 12:43:10 +0200 |
| commit | cf3d0f8d519ca1b43c78d5dde9f5b43fec6e3334 (patch) | |
| tree | e1f83eeb7920f3c68fc3d5f41242e3d24958227d /windows/helpers | |
| parent | b16da095493bc207f4196b8b61cfc768a237a5bc (diff) | |
| parent | 0011e8df47380936742302ef40639a4626a780ed (diff) | |
Merge remote-tracking branch 'remotes/upstream/api-migration' into api-system
Diffstat (limited to 'windows/helpers')
| -rw-r--r-- | windows/helpers/ShowError.nsh | 10 | ||||
| -rw-r--r-- | windows/helpers/StrSlash.nsh | 47 |
2 files changed, 57 insertions, 0 deletions
diff --git a/windows/helpers/ShowError.nsh b/windows/helpers/ShowError.nsh new file mode 100644 index 000000000..6e09b1e40 --- /dev/null +++ b/windows/helpers/ShowError.nsh @@ -0,0 +1,10 @@ +; Show error +!macro ShowError TEXT RETRYLABEL + MessageBox MB_ABORTRETRYIGNORE|MB_ICONSTOP "${TEXT}" IDIGNORE +2 IDRETRY ${RETRYLABEL} + Abort +!macroend + +!macro ShowErrorFinal TEXT + MessageBox MB_OK|MB_ICONSTOP "${TEXT}" + Abort +!macroend diff --git a/windows/helpers/StrSlash.nsh b/windows/helpers/StrSlash.nsh new file mode 100644 index 000000000..b8aa771aa --- /dev/null +++ b/windows/helpers/StrSlash.nsh @@ -0,0 +1,47 @@ +; Adapted from: https://nsis.sourceforge.io/Another_String_Replace_(and_Slash/BackSlash_Converter) (2019-08-31) + +!macro _StrSlashConstructor out in + Push "${in}" + Push "\" + Call StrSlash + Pop ${out} +!macroend + +!define StrSlash '!insertmacro "_StrSlashConstructor"' + +; Push $filenamestring (e.g. 'c:\this\and\that\filename.htm') +; Push "\" +; Call StrSlash +; Pop $R0 +; ;Now $R0 contains 'c:/this/and/that/filename.htm' +Function StrSlash + Exch $R3 ; $R3 = needle ("\" or "/") + Exch + Exch $R1 ; $R1 = String to replacement in (haystack) + Push $R2 ; Replaced haystack + Push $R4 ; $R4 = not $R3 ("/" or "\") + Push $R6 + Push $R7 ; Scratch reg + StrCpy $R2 "" + StrLen $R6 $R1 + StrCpy $R4 "\" + StrCmp $R3 "/" loop + StrCpy $R4 "/" +loop: + StrCpy $R7 $R1 1 + StrCpy $R1 $R1 $R6 1 + StrCmp $R7 $R3 found + StrCpy $R2 "$R2$R7" + StrCmp $R1 "" done loop +found: + StrCpy $R2 "$R2$R4" + StrCmp $R1 "" done loop +done: + StrCpy $R3 $R2 + Pop $R7 + Pop $R6 + Pop $R4 + Pop $R2 + Pop $R1 + Exch $R3 +FunctionEnd |
